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

Custom customer attribute not showing on frontend

I’ve seen this question many times, but all the solutions I’ve tried didn’t work. I’ve generated a module that creates three custom attributes in customer’s information. Since I’m new to Magento (Magento 2 especially) I’ve done this trough Silk https://www.silksoftware.com/magento-module-creator/magento2-module-creator.php I can see the three attributes fine in the backend, now I need to show […]

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

how to restrict an EAV attribute for some roles

i have make and EAV attribute and this custom attribute was displayed for all the users, but i want it to be displayed just for some roles like ‘admin’ and ‘role1’ not for all can anyone tell me how to do it please, here is my code : public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { […]

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 extension attribute value is coming null

I an creating a customer address attribute using this code <?php namespace Ansh\CustomAddressAttribute\Setup; use Magento\Customer\Model\Customer; use Magento\Customer\Setup\CustomerSetup; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\UpgradeDataInterface; use Magento\Framework\Setup\ModuleDataSetupInterface; class UpgradeData implements UpgradeDataInterface { private $customerSetupFactory; public function __construct(\Magento\Customer\Setup\CustomerSetupFactory $customerSetupFactory) { $this->customerSetupFactory = $customerSetupFactory; } public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context){ $setup->startSetup(); /** @var CustomerSetup $customerSetup */ $customerSetup = $this->customerSetupFactory->create([‘setup’ => […]

Categories
CMS Magento Mastering Development

magento 2 extension attribute value is coming null

I an creating a customer address attribute using this code <?php namespace Ansh\CustomAddressAttribute\Setup; use Magento\Customer\Model\Customer; use Magento\Customer\Setup\CustomerSetup; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\UpgradeDataInterface; use Magento\Framework\Setup\ModuleDataSetupInterface; class UpgradeData implements UpgradeDataInterface { private $customerSetupFactory; public function __construct(\Magento\Customer\Setup\CustomerSetupFactory $customerSetupFactory) { $this->customerSetupFactory = $customerSetupFactory; } public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context){ $setup->startSetup(); /** @var CustomerSetup $customerSetup */ $customerSetup = $this->customerSetupFactory->create([‘setup’ => […]

Categories
CMS Magento Mastering Development

Magento 2 custom checkout select field shippingAdditional add or remove require-entry upon selected shipping method

If Free Shipping Method is selected change validation E.G:’validation’ => [‘required-entry’ => false], … ‘custom_field’ => [ ‘component’ => ‘Vendor_Module/js/custom-field-component’, ‘config’ => [ ‘customScope’ => ‘shippingAddress.custom_attributes’, ‘template’ => ‘ui/form/field’, ‘elementTmpl’ => ‘Vendor_Module/fields/select’, ‘options’ => $this->getOptions(), ‘id’ => ‘custom_field’ ], ‘dataScope’ => ‘custom_scope.custom_field’, ‘label’ => ‘Select Option’, ‘provider’ => ‘checkoutProvider’, ‘visible’ => true, ‘validation’ => [‘required-entry’ […]