ltsecurityinc安防产品在线商城代码

This commit is contained in:
2026-09-14 17:47:10 +08:00
parent 57d8444c15
commit 6a3c9c5bd8
14539 changed files with 1775310 additions and 0 deletions
+107
View File
@@ -0,0 +1,107 @@
<?php
namespace Olegnax\ProductLabel\Setup;
use Magento\Catalog\Model\Product;
use Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface;
use Magento\Eav\Model\Entity\Attribute\Source\Boolean;
use Magento\Eav\Setup\EavSetupFactory;
use Magento\Framework\Setup\InstallDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
class InstallData implements InstallDataInterface
{
private $eavSetupFactory;
/**
* Constructor
*
* @param EavSetupFactory $eavSetupFactory
*/
public function __construct(EavSetupFactory $eavSetupFactory)
{
$this->eavSetupFactory = $eavSetupFactory;
}
/**
* {@inheritdoc}
*/
public function install(
ModuleDataSetupInterface $setup,
ModuleContextInterface $context
) {
$setup->startSetup();
$this->_install($setup);
$setup->endSetup();
}
private function _install(ModuleDataSetupInterface $setup)
{
$eavSetup = $this->eavSetupFactory->create([
'setup' => $setup,
]);
$tablefields = $this->fields();
foreach ($tablefields as $entity => $fields) {
foreach ($fields as $key => $value) {
$eavSetup->addAttribute($entity, $key, $value);
}
}
}
private function fields()
{
return [
Product::ENTITY => [
'ox_featured' => [
'group' => 'Product Details',
'type' => 'int',
'backend' => '',
'frontend' => '',
'label' => 'Featured Product',
'input' => 'boolean',
'class' => '',
'source' => Boolean::class,
'sort_order' => 3,
'global' => ScopedAttributeInterface::SCOPE_GLOBAL,
'visible' => true,
'required' => false,
'user_defined' => true,
'default' => '0',
'searchable' => false,
'filterable' => false,
'comparable' => false,
'visible_on_front' => false,
'used_in_product_listing' => true,
'unique' => false,
'apply_to' => '',
],
'ox_custom' => [
'group' => 'Product Details',
'type' => 'int',
'backend' => '',
'frontend' => '',
'label' => 'Custom Label',
'input' => 'boolean',
'class' => '',
'source' => Boolean::class,
'sort_order' => 4,
'global' => ScopedAttributeInterface::SCOPE_GLOBAL,
'visible' => true,
'required' => false,
'user_defined' => true,
'default' => '0',
'searchable' => false,
'filterable' => false,
'comparable' => false,
'visible_on_front' => false,
'used_in_product_listing' => true,
'unique' => false,
'apply_to' => '',
],
],
];
}
}
@@ -0,0 +1,110 @@
<?php
namespace Olegnax\ProductLabel\Setup\Patch\Data;
use Magento\Catalog\Model\Product;
use Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface;
use Magento\Eav\Model\Entity\Attribute\Source\Boolean;
use Magento\Eav\Setup\EavSetup;
use Magento\Eav\Setup\EavSetupFactory;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Framework\Setup\Patch\PatchRevertableInterface;
class AddOxCustomProductAttribute implements DataPatchInterface, PatchRevertableInterface
{
/**
* @var ModuleDataSetupInterface
*/
private $moduleDataSetup;
/**
* @var EavSetupFactory
*/
private $eavSetupFactory;
/**
* Constructor
*
* @param ModuleDataSetupInterface $moduleDataSetup
* @param EavSetupFactory $eavSetupFactory
*/
public function __construct(
ModuleDataSetupInterface $moduleDataSetup,
EavSetupFactory $eavSetupFactory
) {
$this->moduleDataSetup = $moduleDataSetup;
$this->eavSetupFactory = $eavSetupFactory;
}
/**
* {@inheritdoc}
*/
public static function getDependencies()
{
return [
];
}
/**
* {@inheritdoc}
*/
public function apply()
{
$this->moduleDataSetup->getConnection()->startSetup();
/** @var EavSetup $eavSetup */
$eavSetup = $this->eavSetupFactory->create(['setup' => $this->moduleDataSetup]);
$eavSetup->addAttribute(
Product::ENTITY,
'ox_custom',
[
'apply_to' => '',
'backend' => '',
'class' => '',
'comparable' => false,
'default' => '0',
'filterable' => false,
'frontend' => '',
'global' => ScopedAttributeInterface::SCOPE_GLOBAL,
'group' => 'Product Details',
'input' => 'boolean',
'label' => 'Custom Label',
'required' => false,
'searchable' => false,
'sort_order' => 4,
'source' => Boolean::class,
'type' => 'int',
'unique' => false,
'used_in_product_listing' => true,
'user_defined' => true,
'visible' => true,
'visible_on_front' => false,
]
);
$this->moduleDataSetup->getConnection()->endSetup();
}
/**
* {@inheritdoc}
*/
public function revert()
{
$this->moduleDataSetup->getConnection()->startSetup();
/** @var EavSetup $eavSetup */
$eavSetup = $this->eavSetupFactory->create(['setup' => $this->moduleDataSetup]);
$eavSetup->removeAttribute(Product::ENTITY, 'ox_custom');
$this->moduleDataSetup->getConnection()->endSetup();
}
/**
* {@inheritdoc}
*/
public function getAliases()
{
return [];
}
}
+96
View File
@@ -0,0 +1,96 @@
<?php
namespace Olegnax\ProductLabel\Setup;
use Magento\Catalog\Model\Product;
use Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface;
use Magento\Eav\Model\Entity\Attribute\Source\Boolean;
use Magento\Eav\Setup\EavSetup;
use Magento\Eav\Setup\EavSetupFactory;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\UpgradeDataInterface;
class UpgradeData implements UpgradeDataInterface
{
private $eavSetupFactory;
/**
* Constructor
*
* @param EavSetupFactory $eavSetupFactory
*/
public function __construct(EavSetupFactory $eavSetupFactory)
{
$this->eavSetupFactory = $eavSetupFactory;
}
/**
* @param ModuleDataSetupInterface $setup
* @param ModuleContextInterface $context
*/
public function upgrade(
ModuleDataSetupInterface $setup,
ModuleContextInterface $context
) {
$methods = $this->getUpgradeFunctions($context->getVersion());
$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
foreach ($methods as $method) {
call_user_func_array([$this, $method], [$setup, $eavSetup]);
}
}
private function getUpgradeFunctions($low_version = '1.0.0')
{
$methods = get_class_methods($this);
foreach ($methods as $key => $method) {
if (preg_match('/^upgrade_(.+)$/i', $method, $matches)) {
if (version_compare($low_version, $matches[1], '<')) {
continue;
}
}
unset($methods[$key]);
}
$methods = array_filter($methods);
$methods = array_unique($methods);
sort($methods);
return $methods;
}
public function upgrade_0_0_11(
ModuleDataSetupInterface $setup,
EavSetup $eavSetup
) {
$eavSetup->addAttribute(
Product::ENTITY,
'ox_custom',
[
'group' => 'Product Details',
'type' => 'int',
'backend' => '',
'frontend' => '',
'label' => 'Custom Label',
'input' => 'boolean',
'class' => '',
'source' => Boolean::class,
'sort_order' => 4,
'global' => ScopedAttributeInterface::SCOPE_GLOBAL,
'visible' => true,
'required' => false,
'user_defined' => true,
'default' => '0',
'searchable' => false,
'filterable' => false,
'comparable' => false,
'visible_on_front' => false,
'used_in_product_listing' => true,
'unique' => false,
'apply_to' => '',
]
);
}
}