This commit is contained in:
2026-09-15 10:35:56 +08:00
commit 782f8ea7aa
4086 changed files with 631288 additions and 0 deletions
@@ -0,0 +1,62 @@
<?php
declare(strict_types=1);
namespace Esun\Catalog\Setup\Patch\Data;
use Esun\Catalog\Model\Product\Attribute\Backend\JsonRows;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Setup\CategorySetupFactory;
use Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
class AddCertificationDownloadsAttribute implements DataPatchInterface
{
public const ATTRIBUTE_CODE = 'esun_certification_downloads';
public function __construct(
private readonly ModuleDataSetupInterface $moduleDataSetup,
private readonly CategorySetupFactory $categorySetupFactory
) {
}
public function apply(): self
{
$this->moduleDataSetup->getConnection()->startSetup();
$catalogSetup = $this->categorySetupFactory->create(['setup' => $this->moduleDataSetup]);
$catalogSetup->addAttribute(Product::ENTITY, self::ATTRIBUTE_CODE, [
'type' => 'text',
'label' => 'Certification Downloads',
'input' => 'textarea',
'backend_model' => JsonRows::class,
'required' => false,
'sort_order' => 150,
'global' => ScopedAttributeInterface::SCOPE_STORE,
'group' => 'Product Detail Content',
'visible' => false,
'user_defined' => true,
'is_html_allowed_on_front' => 0,
'visible_on_front' => false,
'apply_to' => 'simple,configurable',
'is_used_in_grid' => false,
'is_visible_in_grid' => false,
'is_filterable_in_grid' => false,
]);
$this->moduleDataSetup->getConnection()->endSetup();
return $this;
}
public static function getDependencies(): array
{
return [
UpgradeProductDetailContentAttributes::class,
];
}
public function getAliases(): array
{
return [];
}
}
@@ -0,0 +1,59 @@
<?php
declare(strict_types=1);
namespace Esun\Catalog\Setup\Patch\Data;
use Esun\Catalog\Model\Product\Attribute\Backend\MixStepPrices;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Setup\CategorySetupFactory;
use Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
class AddMixStepPricesAttribute implements DataPatchInterface
{
public const ATTRIBUTE_CODE = 'esun_mix_step_prices';
public function __construct(
private readonly ModuleDataSetupInterface $moduleDataSetup,
private readonly CategorySetupFactory $categorySetupFactory
) {
}
public function apply(): self
{
$this->moduleDataSetup->getConnection()->startSetup();
$catalogSetup = $this->categorySetupFactory->create(['setup' => $this->moduleDataSetup]);
$catalogSetup->addAttribute(Product::ENTITY, self::ATTRIBUTE_CODE, [
'type' => 'text',
'label' => 'Mix Step Prices',
'input' => 'textarea',
'backend' => MixStepPrices::class,
'required' => false,
'sort_order' => 100,
'global' => ScopedAttributeInterface::SCOPE_WEBSITE,
'group' => 'Advanced Pricing',
'visible' => false,
'user_defined' => true,
'visible_on_front' => false,
'apply_to' => 'configurable',
'is_used_in_grid' => false,
'is_visible_in_grid' => false,
'is_filterable_in_grid' => false,
]);
$this->moduleDataSetup->getConnection()->endSetup();
return $this;
}
public static function getDependencies(): array
{
return [];
}
public function getAliases(): array
{
return [];
}
}
@@ -0,0 +1,64 @@
<?php
declare(strict_types=1);
namespace Esun\Catalog\Setup\Patch\Data;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Setup\CategorySetupFactory;
use Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
class AddProductDetailContentAttributes implements DataPatchInterface
{
private const ATTRIBUTES = [
'esun_industry_applications' => 'Industry Applications',
'esun_detail_gallery' => 'Detail Gallery Media IDs',
'esun_creative_video_ids' => 'Creative Videos',
'esun_product_faqs' => 'Product FAQs',
];
public function __construct(
private readonly ModuleDataSetupInterface $moduleDataSetup,
private readonly CategorySetupFactory $categorySetupFactory
) {
}
public function apply(): void
{
$this->moduleDataSetup->getConnection()->startSetup();
$categorySetup = $this->categorySetupFactory->create(['setup' => $this->moduleDataSetup]);
foreach (self::ATTRIBUTES as $code => $label) {
$categorySetup->addAttribute(Product::ENTITY, $code, [
'type' => 'text',
'label' => $label,
'input' => 'textarea',
'required' => false,
'sort_order' => 110,
'global' => ScopedAttributeInterface::SCOPE_STORE,
'group' => 'Product Detail Content',
'visible' => true,
'user_defined' => true,
'is_html_allowed_on_front' => $code === 'esun_product_faqs',
'visible_on_front' => false,
'apply_to' => 'simple,configurable',
'is_used_in_grid' => false,
'is_visible_in_grid' => false,
'is_filterable_in_grid' => false,
]);
}
$this->moduleDataSetup->getConnection()->endSetup();
}
public static function getDependencies(): array
{
return [];
}
public function getAliases(): array
{
return [];
}
}
@@ -0,0 +1,62 @@
<?php
declare(strict_types=1);
namespace Esun\Catalog\Setup\Patch\Data;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Setup\CategorySetupFactory;
use Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
class AddProductOverviewAttribute implements DataPatchInterface
{
public const ATTRIBUTE_CODE = 'product_overview';
public function __construct(
private readonly ModuleDataSetupInterface $moduleDataSetup,
private readonly CategorySetupFactory $categorySetupFactory
) {
}
public function apply(): void
{
$this->moduleDataSetup->getConnection()->startSetup();
$categorySetup = $this->categorySetupFactory->create(['setup' => $this->moduleDataSetup]);
$categorySetup->addAttribute(
Product::ENTITY,
self::ATTRIBUTE_CODE,
[
'type' => 'text',
'label' => 'Product Overview',
'input' => 'textarea',
'required' => false,
'sort_order' => 85,
'global' => ScopedAttributeInterface::SCOPE_STORE,
'group' => 'Content',
'visible' => true,
'user_defined' => true,
'wysiwyg_enabled' => true,
'is_html_allowed_on_front' => true,
'visible_on_front' => false,
'apply_to' => 'simple,configurable',
'is_used_in_grid' => false,
'is_visible_in_grid' => false,
'is_filterable_in_grid' => false,
]
);
$this->moduleDataSetup->getConnection()->endSetup();
}
public static function getDependencies(): array
{
return [];
}
public function getAliases(): array
{
return [];
}
}
@@ -0,0 +1,89 @@
<?php
declare(strict_types=1);
namespace Esun\Catalog\Setup\Patch\Data;
use Magento\Cms\Model\BlockFactory;
use Magento\Cms\Model\ResourceModel\Block as BlockResource;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
class AddProductServiceCmsBlocks implements DataPatchInterface
{
private const DELIVERY_BLOCK_ID = 'esun_product_delivery_shipping';
private const PAYMENT_BLOCK_ID = 'esun_product_payment_security';
public function __construct(
private readonly ModuleDataSetupInterface $moduleDataSetup,
private readonly BlockFactory $blockFactory,
private readonly BlockResource $blockResource
) {
}
public function apply(): void
{
$this->moduleDataSetup->getConnection()->startSetup();
$this->saveBlock(
self::DELIVERY_BLOCK_ID,
'Product Detail - Delivery and Shipping',
<<<'HTML'
<div class="esun-product-service esun-product-service--delivery">
<ul>
<li>Shipping: $ 5.99, Free Shipping Over $ 99.00</li>
<li><a href="{{store url='shipping-policy'}}">To United States Via FedEX/USPS</a></li>
<li>Estimated Delivery Time: Standard Shipping</li>
</ul>
</div>
HTML
);
$this->saveBlock(
self::PAYMENT_BLOCK_ID,
'Product Detail - Payment & Security',
<<<'HTML'
<div class="esun-product-service esun-product-service--payment">
<div class="esun-payment-methods__label">Payment Methods</div>
<div class="esun-payment-methods" aria-label="Payment Methods">
<span>PayPal</span>
<span>Apple Pay</span>
<span>Google Pay</span>
<span>Klarna</span>
<span>VISA</span>
<span>Mastercard</span>
<span>Maestro</span>
<span>JCB</span>
<span>AmEx</span>
<span>Diners Club</span>
<span>Discover</span>
</div>
<p>Your Payment Information Is Processed Securely. We Do Not Store Credit Card Details Nor Have Access To Your Credit Card Information.</p>
</div>
HTML
);
$this->moduleDataSetup->getConnection()->endSetup();
}
private function saveBlock(string $identifier, string $title, string $content): void
{
$block = $this->blockFactory->create();
$this->blockResource->load($block, $identifier, 'identifier');
$block->setData('identifier', $identifier);
$block->setData('title', $title);
$block->setData('content', $content);
$block->setData('is_active', 1);
$block->setData('stores', [0]);
$this->blockResource->save($block);
}
public static function getDependencies(): array
{
return [];
}
public function getAliases(): array
{
return [];
}
}
@@ -0,0 +1,50 @@
<?php
declare(strict_types=1);
namespace Esun\Catalog\Setup\Patch\Data;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Setup\CategorySetupFactory;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
class HideProductDetailContentRawAttributes implements DataPatchInterface
{
private const ATTRIBUTE_CODES = [
'esun_industry_applications',
'esun_detail_gallery',
'esun_creative_video_ids',
'esun_product_faqs',
];
public function __construct(
private readonly ModuleDataSetupInterface $moduleDataSetup,
private readonly CategorySetupFactory $categorySetupFactory
) {
}
public function apply(): self
{
$this->moduleDataSetup->getConnection()->startSetup();
$catalogSetup = $this->categorySetupFactory->create(['setup' => $this->moduleDataSetup]);
foreach (self::ATTRIBUTE_CODES as $attributeCode) {
$catalogSetup->updateAttribute(Product::ENTITY, $attributeCode, 'visible', 0);
}
$this->moduleDataSetup->getConnection()->endSetup();
return $this;
}
public static function getDependencies(): array
{
return [
UpgradeProductDetailContentAttributes::class,
];
}
public function getAliases(): array
{
return [];
}
}
@@ -0,0 +1,50 @@
<?php
declare(strict_types=1);
namespace Esun\Catalog\Setup\Patch\Data;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Setup\CategorySetupFactory;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
class HideProductDetailContentRawAttributesV2 implements DataPatchInterface
{
private const ATTRIBUTE_CODES = [
'esun_industry_applications',
'esun_detail_gallery',
'esun_creative_video_ids',
'esun_product_faqs',
];
public function __construct(
private readonly ModuleDataSetupInterface $moduleDataSetup,
private readonly CategorySetupFactory $categorySetupFactory
) {
}
public function apply(): self
{
$this->moduleDataSetup->getConnection()->startSetup();
$catalogSetup = $this->categorySetupFactory->create(['setup' => $this->moduleDataSetup]);
foreach (self::ATTRIBUTE_CODES as $attributeCode) {
$catalogSetup->updateAttribute(Product::ENTITY, $attributeCode, 'is_visible', 0);
}
$this->moduleDataSetup->getConnection()->endSetup();
return $this;
}
public static function getDependencies(): array
{
return [
HideProductDetailContentRawAttributes::class,
];
}
public function getAliases(): array
{
return [];
}
}
@@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
namespace Esun\Catalog\Setup\Patch\Data;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Setup\CategorySetupFactory;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
class RemoveFreeShippingQuantityAttribute implements DataPatchInterface
{
private const ATTRIBUTE_CODE = 'free_shipping_quantity';
public function __construct(
private readonly ModuleDataSetupInterface $moduleDataSetup,
private readonly CategorySetupFactory $categorySetupFactory
) {
}
public function apply(): void
{
$this->moduleDataSetup->getConnection()->startSetup();
$categorySetup = $this->categorySetupFactory->create(['setup' => $this->moduleDataSetup]);
$categorySetup->removeAttribute(Product::ENTITY, self::ATTRIBUTE_CODE);
$this->moduleDataSetup->getConnection()->endSetup();
}
public static function getDependencies(): array
{
return [];
}
public function getAliases(): array
{
return [];
}
}
@@ -0,0 +1,48 @@
<?php
declare(strict_types=1);
namespace Esun\Catalog\Setup\Patch\Data;
use Esun\Catalog\Model\Product\Attribute\Backend\JsonRows;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Setup\CategorySetupFactory;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
class UpgradeCertificationDownloadsAttribute implements DataPatchInterface
{
public function __construct(
private readonly ModuleDataSetupInterface $moduleDataSetup,
private readonly CategorySetupFactory $categorySetupFactory
) {
}
public function apply(): self
{
$this->moduleDataSetup->getConnection()->startSetup();
$catalogSetup = $this->categorySetupFactory->create(['setup' => $this->moduleDataSetup]);
$catalogSetup->updateAttribute(Product::ENTITY, AddCertificationDownloadsAttribute::ATTRIBUTE_CODE, [
'backend_model' => JsonRows::class,
'is_html_allowed_on_front' => 0,
'is_wysiwyg_enabled' => 0,
'is_pagebuilder_enabled' => 0,
'is_visible' => 0,
]);
$this->moduleDataSetup->getConnection()->endSetup();
return $this;
}
public static function getDependencies(): array
{
return [
AddCertificationDownloadsAttribute::class,
];
}
public function getAliases(): array
{
return [];
}
}
@@ -0,0 +1,44 @@
<?php
declare(strict_types=1);
namespace Esun\Catalog\Setup\Patch\Data;
use Esun\Catalog\Model\Product\Attribute\Backend\MixStepPrices;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Setup\CategorySetupFactory;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
class UpgradeMixStepPricesAttribute implements DataPatchInterface
{
public function __construct(
private readonly ModuleDataSetupInterface $moduleDataSetup,
private readonly CategorySetupFactory $categorySetupFactory
) {
}
public function apply(): self
{
$this->moduleDataSetup->getConnection()->startSetup();
$catalogSetup = $this->categorySetupFactory->create(['setup' => $this->moduleDataSetup]);
$catalogSetup->updateAttribute(
Product::ENTITY,
AddMixStepPricesAttribute::ATTRIBUTE_CODE,
'backend_model',
MixStepPrices::class
);
$this->moduleDataSetup->getConnection()->endSetup();
return $this;
}
public static function getDependencies(): array
{
return [AddMixStepPricesAttribute::class];
}
public function getAliases(): array
{
return [];
}
}
@@ -0,0 +1,56 @@
<?php
declare(strict_types=1);
namespace Esun\Catalog\Setup\Patch\Data;
use Esun\Catalog\Model\Product\Attribute\Backend\JsonRows;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Setup\CategorySetupFactory;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
class UpgradeProductDetailContentAttributes implements DataPatchInterface
{
private const ATTRIBUTE_CODES = [
'esun_industry_applications',
'esun_detail_gallery',
'esun_creative_video_ids',
'esun_product_faqs',
];
public function __construct(
private readonly ModuleDataSetupInterface $moduleDataSetup,
private readonly CategorySetupFactory $categorySetupFactory
) {
}
public function apply(): self
{
$this->moduleDataSetup->getConnection()->startSetup();
$catalogSetup = $this->categorySetupFactory->create(['setup' => $this->moduleDataSetup]);
foreach (self::ATTRIBUTE_CODES as $attributeCode) {
$catalogSetup->updateAttribute(Product::ENTITY, $attributeCode, [
'backend_model' => JsonRows::class,
'is_html_allowed_on_front' => $attributeCode === 'esun_product_faqs' ? 1 : 0,
'is_wysiwyg_enabled' => $attributeCode === 'esun_product_faqs' ? 1 : 0,
'is_pagebuilder_enabled' => $attributeCode === 'esun_product_faqs' ? 1 : 0,
]);
}
$this->moduleDataSetup->getConnection()->endSetup();
return $this;
}
public static function getDependencies(): array
{
return [
AddProductDetailContentAttributes::class,
];
}
public function getAliases(): array
{
return [];
}
}