-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v1.0.4 Added is_qwqer_available attribute to products
- Loading branch information
Andrew
committed
Mar 6, 2024
1 parent
7b68591
commit 2b66725
Showing
8 changed files
with
193 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
<?php | ||
|
||
namespace Qwqer\Express\Setup\Patch\Data; | ||
|
||
use Magento\Catalog\Model\Product; | ||
use Magento\Catalog\Model\ResourceModel\Eav\Attribute; | ||
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; | ||
use Qwqer\Express\Provider\ConfigurationProvider; | ||
class AddQwqerIsAvailableAttribute implements DataPatchInterface, PatchRevertableInterface | ||
{ | ||
/** | ||
* @var \Magento\Framework\Setup\ModuleDataSetupInterface | ||
*/ | ||
private ModuleDataSetupInterface $moduleDataSetup; | ||
|
||
/** | ||
* @var \Magento\Eav\Setup\EavSetupFactory | ||
*/ | ||
private EavSetupFactory $eavSetupFactory; | ||
|
||
/** | ||
* @param EavSetupFactory $eavSetupFactory | ||
* @param ModuleDataSetupInterface $moduleDataSetup | ||
*/ | ||
public function __construct( | ||
EavSetupFactory $eavSetupFactory, | ||
ModuleDataSetupInterface $moduleDataSetup | ||
) | ||
{ | ||
$this->moduleDataSetup = $moduleDataSetup; | ||
$this->eavSetupFactory = $eavSetupFactory; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
* @throws \Magento\Framework\Exception\LocalizedException | ||
*/ | ||
public function apply() | ||
{ | ||
$this->moduleDataSetup->getConnection()->startSetup(); | ||
|
||
/** @var EavSetup $eavSetup */ | ||
$eavSetup = $this->eavSetupFactory->create(['setup' => $this->moduleDataSetup]); | ||
|
||
$attributeId = $eavSetup->getAttributeId( | ||
Product::ENTITY, | ||
ConfigurationProvider::ATTRIBUTE_CODE_AVAILABILITY | ||
); | ||
|
||
if (!$attributeId) { | ||
$eavSetup->addAttribute( | ||
Product::ENTITY, | ||
ConfigurationProvider::ATTRIBUTE_CODE_AVAILABILITY, | ||
[ | ||
'type' => 'int', | ||
'label' => 'Available Qwqer Delivery', | ||
'input' => 'boolean', | ||
'source' => \Magento\Eav\Model\Entity\Attribute\Source\Boolean::class, | ||
'global' => Attribute::SCOPE_WEBSITE, | ||
'visible' => true, | ||
'frontend' => '', | ||
'required' => false, | ||
'searchable' => false, | ||
'filterable' => false, | ||
'comparable' => false, | ||
'visible_on_front' => false, | ||
'used_in_product_listing' => true, | ||
'unique' => false, | ||
'group' => 'General', | ||
'position' => 60 | ||
] | ||
); | ||
} | ||
|
||
$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, ConfigurationProvider::ATTRIBUTE_CODE_AVAILABILITY); | ||
$this->moduleDataSetup->getConnection()->endSetup(); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public static function getDependencies(): array | ||
{ | ||
return []; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function getAliases(): array | ||
{ | ||
return []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0"?> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Catalog:etc/catalog_attributes.xsd"> | ||
<group name="quote_item"> | ||
<attribute name="is_qwqer_available"/> | ||
</group> | ||
</config> |