This commit is contained in:
2026-09-15 10:26:34 +08:00
commit ecf36afa56
10493 changed files with 1404888 additions and 0 deletions
@@ -0,0 +1,63 @@
<?php
namespace Stemcell\Catalog\Setup\Patch\Data;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Eav\Api\AttributeOptionManagementInterface;
use Magento\Eav\Api\Data\AttributeOptionInterfaceFactory;
use Magento\Eav\Api\Data\AttributeOptionLabelInterfaceFactory;
/**
* 给产品的resource_type加一个【中文版分选说明书】的option
*/
class AddChineseEditionCellSeparationOption implements DataPatchInterface
{
const PRODUCT_ATTRIBUTE_CODE = 'resource_type';
const RESOURCE_TYPE_ENGLISH_LABEL = 'Chinese Edition Cell Separation Sheets';
const RESOURCE_TYPE_CHINESE_LABEL = '中文版分选说明书';
const PIS_CN_Label = [self::RESOURCE_TYPE_ENGLISH_LABEL, self::RESOURCE_TYPE_CHINESE_LABEL];
public function __construct(
protected AttributeOptionManagementInterface $optionManagement,
protected AttributeOptionInterfaceFactory $optionFactory,
protected AttributeOptionLabelInterfaceFactory $labelFactory
) {
}
public static function getDependencies()
{
return [];
}
public function getAliases()
{
return [];
}
public function apply()
{
$optionLabel = $this->labelFactory->create();
$optionLabel->setStoreId(0);
$optionLabel->setLabel(self::RESOURCE_TYPE_ENGLISH_LABEL);
$optionLabel1 = $this->labelFactory->create();
$optionLabel1->setStoreId(1);
$optionLabel1->setLabel(self::RESOURCE_TYPE_CHINESE_LABEL);
$option = $this->optionFactory->create();
$option->setLabel('中文版分选说明书');
$option->setStoreLabels([$optionLabel, $optionLabel1]);
$option->setSortOrder(10);
$option->setIsDefault(false);
$this->optionManagement->add(
\Magento\Catalog\Model\Product::ENTITY,
self::PRODUCT_ATTRIBUTE_CODE,
$option
);
}
}
@@ -0,0 +1,99 @@
<?php
/**
* Copyright © All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Stemcell\Catalog\Setup\Patch\Data;
use Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface;
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 AddSearchTagProductAttribute implements DataPatchInterface, PatchRevertableInterface
{
/**
* Constructor
*
* @param ModuleDataSetupInterface $moduleDataSetup
* @param EavSetupFactory $eavSetupFactory
*/
public function __construct(
private ModuleDataSetupInterface $moduleDataSetup,
private EavSetupFactory $eavSetupFactory
) {
}
/**
* {@inheritdoc}
*/
public function apply(): void
{
$this->moduleDataSetup->getConnection()->startSetup();
/** @var EavSetup $eavSetup */
$eavSetup = $this->eavSetupFactory->create(['setup' => $this->moduleDataSetup]);
$eavSetup->addAttribute(
\Magento\Catalog\Model\Product::ENTITY,
'search_tags',
[
'type' => 'text',
'label' => 'Search Tags',
'input' => 'textarea',
'source' => '',
'frontend' => '',
'required' => false,
'backend' => '',
'sort_order' => '30',
'global' => ScopedAttributeInterface::SCOPE_STORE,
'default' => null,
'visible' => true,
'user_defined' => true,
'searchable' => true,
'search_weight' => 4,
'filterable' => false,
'comparable' => false,
'visible_on_front' => false,
'unique' => false,
'apply_to' => '',
'group' => 'General',
'used_in_product_listing' => false,
'is_used_in_grid' => true,
'is_visible_in_grid' => false,
'is_filterable_in_grid' => false
]
);
$this->moduleDataSetup->getConnection()->endSetup();
}
public function revert(): void
{
$this->moduleDataSetup->getConnection()->startSetup();
/** @var EavSetup $eavSetup */
$eavSetup = $this->eavSetupFactory->create(['setup' => $this->moduleDataSetup]);
$eavSetup->removeAttribute(\Magento\Catalog\Model\Product::ENTITY, 'search_tags');
$this->moduleDataSetup->getConnection()->endSetup();
}
/**
* {@inheritdoc}
*/
public function getAliases(): array
{
return [];
}
/**
* {@inheritdoc}
*/
public static function getDependencies(): array
{
return [];
}
}
@@ -0,0 +1,100 @@
<?php
/**
* Copyright © All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Stemcell\Catalog\Setup\Patch\Data;
use Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface;
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 AddSearchWordsProductAttribute implements DataPatchInterface, PatchRevertableInterface
{
/**
* Constructor
*
* @param ModuleDataSetupInterface $moduleDataSetup
* @param EavSetupFactory $eavSetupFactory
*/
public function __construct(
private ModuleDataSetupInterface $moduleDataSetup,
private EavSetupFactory $eavSetupFactory
) {
}
/**
* {@inheritdoc}
*/
public function apply(): void
{
$this->moduleDataSetup->getConnection()->startSetup();
/** @var EavSetup $eavSetup */
$eavSetup = $this->eavSetupFactory->create(['setup' => $this->moduleDataSetup]);
$eavSetup->addAttribute(
\Magento\Catalog\Model\Product::ENTITY,
'search_words',
[
'type' => 'varchar',
'label' => 'Search Words',
'input' => 'text',
'source' => '',
'frontend' => '',
'required' => false,
'backend' => '',
'sort_order' => '30',
'global' => ScopedAttributeInterface::SCOPE_STORE,
'default' => null,
'visible' => true,
'user_defined' => true,
'searchable' => true,
'search_weight' => 10,
'filterable' => false,
'comparable' => false,
'visible_on_front' => false,
'unique' => false,
'apply_to' => '',
'group' => 'General',
'used_in_product_listing' => false,
'is_used_in_grid' => true,
'is_visible_in_grid' => false,
'is_filterable_in_grid' => false,
'option' => array('values' => array(""))
]
);
$this->moduleDataSetup->getConnection()->endSetup();
}
public function revert(): void
{
$this->moduleDataSetup->getConnection()->startSetup();
/** @var EavSetup $eavSetup */
$eavSetup = $this->eavSetupFactory->create(['setup' => $this->moduleDataSetup]);
$eavSetup->removeAttribute(\Magento\Catalog\Model\Product::ENTITY, 'search_words');
$this->moduleDataSetup->getConnection()->endSetup();
}
/**
* {@inheritdoc}
*/
public function getAliases(): array
{
return [];
}
/**
* {@inheritdoc}
*/
public static function getDependencies(): array
{
return [];
}
}