70 lines
2.1 KiB
PHP
Executable File
70 lines
2.1 KiB
PHP
Executable File
<?php
|
|
|
|
namespace Solwin\Cpanel\Setup;
|
|
|
|
|
|
use Magento\Framework\Setup;
|
|
use Magento\Eav\Setup\EavSetup;
|
|
use Magento\Eav\Setup\EavSetupFactory;
|
|
use Magento\Framework\Setup\InstallDataInterface;
|
|
use Magento\Framework\Setup\ModuleContextInterface;
|
|
use Magento\Framework\Setup\ModuleDataSetupInterface;
|
|
|
|
/**
|
|
* @codeCoverageIgnore
|
|
*/
|
|
class InstallData implements InstallDataInterface {
|
|
|
|
/**
|
|
* EAV setup factory
|
|
*
|
|
* @var EavSetupFactory
|
|
*/
|
|
private $eavSetupFactory;
|
|
|
|
/**
|
|
* Init
|
|
*
|
|
* @param EavSetupFactory $eavSetupFactory
|
|
*/
|
|
public function __construct(EavSetupFactory $eavSetupFactory, Setup\SampleData\Executor $executor, Installer $installer) {
|
|
$this->eavSetupFactory = $eavSetupFactory;
|
|
$this->executor = $executor;
|
|
$this->installer = $installer;
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) {
|
|
/** @var EavSetup $eavSetup */
|
|
$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
|
|
|
|
$eavSetup->addAttribute(
|
|
\Magento\Catalog\Model\Product::ENTITY, 'is_featured', [
|
|
'group' => 'Product Details',
|
|
'type' => 'int',
|
|
'sort_order' => 102,
|
|
'backend' => '',
|
|
'frontend' => '',
|
|
'label' => 'Is Featured?',
|
|
'input' => 'boolean',
|
|
'class' => '',
|
|
'source' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean',
|
|
'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_GLOBAL,
|
|
'visible' => true,
|
|
'required' => false,
|
|
'user_defined' => true,
|
|
'default' => '',
|
|
'searchable' => false,
|
|
'filterable' => false,
|
|
'comparable' => false,
|
|
'visible_on_front' => false,
|
|
'used_in_product_listing' => true,
|
|
'unique' => false,
|
|
'apply_to' => 'simple,configurable,virtual,bundle,downloadable'
|
|
]);
|
|
$this->executor->exec($this->installer);
|
|
}
|
|
}
|