PHP code example of mediarox / module-catalog-attribute-setup
1. Go to this page and download the library: Download mediarox/module-catalog-attribute-setup library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mediarox / module-catalog-attribute-setup example snippets
use Catalog\AttributeSetup\Setup\AttributeSetup;
use Catalog\AttributeSetup\Setup\AttributeSetupFactory;
use Magento\Catalog\Model\Product;
use Magento\Framework\Setup\InstallDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Catalog\AttributeSetup\Setup\AttributeSetup;
use Catalog\AttributeSetup\Setup\AttributeSetupFactory;
class RecurringData implements InstallDataInterface
{
protected AttributeSetupFactory $attributeSetup;
public function __construct(
AttributeSetupFactory $attributeSetup
) {
$this->attributeSetup = $attributeSetup;
}
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
/** @var AttributeSetup $attributeSetup */
$attributeSetup = $this->attributeSetup->create([
'setup' => $setup,
'attributeData' => $this->getAttributes()
]);
$setup->startSetup();
$attributeSetup->addUpdateAttributes();
$setup->endSetup();
}
public function getAttributes() : array
{
return [
Product::ENTITY => [
'manufacturer' => [
'is_filterable' => 0
]
]
];
}
}
$attributeSetup = $this->attributeSetup->create([
'setup' => $setup,
'attributeData' => $this->getAttributes()
]);
$attributeSetup->addUpdateAttributes();
<your_module>/Setup/RecurringData.php