Categories
CMS Magento Mastering Development

Custom category attribute is not being saved – issue

I managed to create my custom attribute: $installer = $setup; $installer->startSetup(); $categorySetup = $this->categorySetupFactory->create([‘setup’ => $setup]); $categorySetup->addAttribute( Category::ENTITY, ‘content_category_page’, [ ‘type’ => ‘int’, ‘label’ => ‘Content Page’, ‘input’ => ‘select’, ‘sort_order’ => 100, ‘source’ => ‘Magento\Catalog\Model\Category\Attribute\Source\Page’, ‘global’ => 2, ‘visible’ => true, ‘required’ => true, ‘user_defined’ => false, ‘default’ => null, ‘group’ => ‘General Information’, […]

Categories
CMS Magento Mastering Development

Install Data is not executed in magento 2

I am trying to create a category attribute: This is my file form Vendor/Module/Setup: use Magento\Catalog\Model\Category; use Magento\Catalog\Setup\CategorySetupFactory; use Magento\Framework\Setup\InstallDataInterface; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\ModuleDataSetupInterface; class InstallData implements InstallDataInterface { private $categorySetupFactory; public function __construct(CategorySetupFactory $categorySetupFactory) { $this->categorySetupFactory = $categorySetupFactory; } public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { $installer = $setup; $installer->startSetup(); $categorySetup = $this->categorySetupFactory->create([‘setup’ => […]

Categories
CMS Magento Mastering Development

Create 3 product attributes of dropdown, with its values

I am not able to make appear 2 of the 3 new attributes in magento_admin_site here is the code in InstallaData.php <?php namespace Ht\Mymodule\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; class InstallData implements InstallDataInterface { private $eavSetupFactory; public function __construct(EavSetupFactory $eavSetupFactory) { $this->eavSetupFactory = $eavSetupFactory; } public function install(ModuleDataSetupInterface $setup, ModuleContextInterface […]

Categories
CMS Magento Mastering Development

eav_attribute_option and eav_attribute_option_value not getting updated after adding custom attribute to customer admin

Basically I have been trying to add custom attribute in customer admin using upgrade data and customer setup. But here I can see in my db that my new custom attribute have been added successfully in eav_attribute,customer_eav_attribute,eav_entity_attribute also I am able to see that attribute in customer/admin/edit form in account information tab where I wanted […]

Categories
CMS Magento Mastering Development

eav_attribute_option and eav_attribute_option_value not getting updated after adding custom attribute to customer admin

Basically I have been trying to add custom attribute in customer admin using upgrade data and customer setup. But here I can see in my db that my new custom attribute have been added successfully in eav_attribute,customer_eav_attribute,eav_entity_attribute also I am able to see that attribute in customer/admin/edit form in account information tab where I wanted […]

Categories
CMS Magento Mastering Development

Magento 2.3: How I can create a text swatch attribute programatically?

In my InstallData class I have the following code, it perfectly creates the attribute for me but this creates it as Dropdown and I need it to be Swatch Text. What option am I missing? $productTypes = [ \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE, \Magento\Catalog\Model\Product\Type::TYPE_VIRTUAL, \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE, \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE, ]; $productTypes = join(‘,’, $productTypes); $eavSetup->addAttribute( \Magento\Catalog\Model\Product::ENTITY, ‘web_volumen’, [ ‘type’ => ‘int’, ‘group’ […]

Categories
CMS Magento Mastering Development

How to create customer attibute dropdown in magento 2.3

I want to create dropdown on registration page in magento2.3.4. I made with Installdata and patch but data is not storing in DB. can you help me out. public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { /** @var CustomerSetup $customerSetup */ $customerSetup = $this->customerSetupFactory->create([‘setup’ => $setup]); $customerEntity = $customerSetup->getEavConfig()->getEntityType(‘customer’); $attributeSetId = $customerEntity->getDefaultAttributeSetId(); /** @var $attributeSet AttributeSet […]

Categories
CMS Magento Mastering Development

Patch Not Working

Patch File: Bedard/CustomGloves/Setup/Patch/Data <?php namespace Bedard\CustomGloves\Setup\Patch\Data; use Magento\Framework\Setup\Patch\DataPatchInterface; use Magento\Framework\Setup\Patch\PatchVersionInterface; class SetupCustomGloveProductAttribute implements DataPatchInterface, PatchVersionInterface { /** @var ModuleDataSetupInterface */ private $moduleDataSetup; /** @var EavSetupFactory */ private $eavSetupFactory; /** * @param ModuleDataSetupInterface $moduleDataSetup * @param EavSetupFactory $eavSetupFactory */ public function __construct( ModuleDataSetupInterface $moduleDataSetup, EavSetupFactory $eavSetupFactory ) { $this->moduleDataSetup = $moduleDataSetup; $this->eavSetupFactory = $eavSetupFactory; } /** […]

Categories
CMS Magento Mastering Development

Add attributes with values Programmatically [duplicate]

I am trying to add attributes with values/options programmatically . I have ran my script on shell but It generates error , here is my script : <?php /* @var $conn Varien_Db_Adapter_Interface */ /* @var $installer Mage_Catalog_Model_Resource_Setup */ $installer = $this; $installer->startSetup(); /** * Entities */ $productEntity = Mage_Catalog_Model_Product::ENTITY; $installer->addAttribute($productEntity, ‘attribut1’, array( ‘type’ => ‘int’, […]

Categories
CMS Magento Mastering Development

Add attributes and their values to existing attribute set programmatically

I want to add 2 groups and their attributes programmatically to an existing Set Group This is the screenshot. Please note that I am willing to add two Groups each one containing 3 attributes the first one and 4 the second one. * The groups are not exisiting, Only the Attribute Set exist This is […]