![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/cartforge.co/app/code/Webkul/PrivateShop/Setup/Patch/Data/ |
<?php /** * Webkul Software * * @category Webkul * @package Webkul_PrivateShop * @author Webkul Software Private Limited * @copyright Webkul Software Private Limited (https://webkul.com) * @license https://store.webkul.com/license.html */ namespace Webkul\PrivateShop\Setup\Patch\Data; use Magento\Framework\Setup\Patch\DataPatchInterface; use Magento\Framework\Setup\ModuleDataSetupInterface; use Magento\Customer\Setup\CustomerSetupFactory; use Magento\Eav\Setup\EavSetupFactory; use Magento\Customer\Model\Customer; use Magento\Catalog\Model\Category; use Magento\Catalog\Model\Product; use Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface; class CustomAttributes implements DataPatchInterface { /** * @var \Magento\Framework\Setup\ModuleDataSetupInterface */ protected $moduleDataSetup; /** * @var \Magento\Customer\Setup\CustomerSetupFactory */ protected $customerSetupFactory; /** * @var \Magento\Eav\Setup\EavSetupFactory */ protected $eavSetupFactory; /** * @param ModuleDataSetupInterface $moduleDataSetup * @param CustomerSetupFactory $customerSetupFactory * @param EavSetupFactory $eavSetupFactory */ public function __construct( ModuleDataSetupInterface $moduleDataSetup, CustomerSetupFactory $customerSetupFactory, EavSetupFactory $eavSetupFactory ) { $this->moduleDataSetup = $moduleDataSetup; $this->customerSetupFactory = $customerSetupFactory; $this->eavSetupFactory = $eavSetupFactory; } /** * @inheritdoc */ public function apply() { $customerSetup = $this->customerSetupFactory->create(['setup' => $this->moduleDataSetup]); $customerSetup->addAttribute(Customer::ENTITY, 'customer_private_group', [ 'type' => 'varchar', 'label' => 'Visibility Group', 'input' => 'text', 'source' => '', 'required' => false, 'visible' => false, 'position' => 333, 'system' => false, 'backend' => '' ]); $attribute = $customerSetup->getEavConfig()->getAttribute('customer', 'customer_private_group') ->addData(['used_in_forms' => [ 'adminhtml_customer' ], 'is_used_in_grid' => true, 'is_visible_in_grid' => false ]); $attribute->save(); $eavSetup = $this->eavSetupFactory->create(['setup' => $this->moduleDataSetup]); $eavSetup->addAttribute(Category::ENTITY, 'category_private_group', [ 'type' => 'varchar', 'label' => 'Visibility Group', 'input' => 'text', 'sort_order' => 333, 'source' => '', 'global' => ScopedAttributeInterface::SCOPE_WEBSITE, 'visible' => false, 'required' => false, 'user_defined' => false, 'default' => null, 'group' => 'General Information', 'backend' => '' ]); $eavSetup->addAttribute(Category::ENTITY, 'is_private_category', [ 'type' => 'int', 'label' => 'Private Category', 'input' => 'boolean', 'sort_order' => 333, 'source' => \Magento\Eav\Model\Entity\Attribute\Source\Boolean::class, 'default' => 0, 'visible' => true, 'required' => false, 'user_defined' => true, 'default' => null, 'global' => ScopedAttributeInterface::SCOPE_WEBSITE, 'group' => 'General Information', 'backend' => '' ]); $eavSetup->addAttribute(\Magento\Catalog\Model\Product::ENTITY, 'product_private_group', [ 'group' => 'Product Details', 'type' => 'varchar', 'backend' => '', 'frontend' => '', 'label' => 'Visibility Group', 'input' => 'text', 'class' => '', 'source' => '', 'global' => ScopedAttributeInterface::SCOPE_WEBSITE, 'sort_order' => 1000, 'visible' => true, 'required' => false, 'user_defined' => true, 'default' => null, 'searchable' => false, 'filterable' => false, 'comparable' => false, 'visible_on_front' => false, 'is_used_in_grid' => false, 'is_visible_in_grid' => false, 'is_filterable_in_grid' => true, 'used_in_product_listing' => true, 'unique' => false, 'apply_to' => '', ]); $eavSetup->addAttribute(Product::ENTITY, 'is_private_product', [ 'group' => 'Product Details', 'type' => 'int', 'backend' => '', 'frontend' => '', 'label' => 'Private Product', 'input' => 'boolean', 'class' => '', 'source' => \Magento\Eav\Model\Entity\Attribute\Source\Boolean::class, 'global' => ScopedAttributeInterface::SCOPE_WEBSITE, 'visible' => true, 'required' => false, 'user_defined' => true, 'default' => 0, 'sort_order' => 999, 'searchable' => true, 'filterable' => true, 'comparable' => true, 'visible_on_front' => true, 'is_used_in_grid' => true, 'visible_in_advanced_search' => true, 'is_visible_in_grid' => false, 'is_filterable_in_grid' => true, 'used_in_product_listing' => true, 'unique' => false, 'apply_to' => '', ]); } /** * @inheritdoc */ public function getAliases() { return []; } /** * @inheritdoc */ public static function getDependencies() { return []; } }