0

So im trying to update the is_visible on update_at attribute which belongs to the product.

Like this

if (version_compare($context->getVersion(), '0.4.8', '<='))
        {
            $this->eavSetup->updateAttribute('catalog_eav_attribute', '113', 'is_visible', 1);
        }

The code runs, but nothing happens, and the value in is_visible on attribute_id -> 113 is still 0

2
  • make sure updated your modules version in module.xml Jun 1, 2021 at 12:56
  • Thank you, it was just magento, that didnt pick it up the first time. Jun 1, 2021 at 13:05

1 Answer 1

1

Use following code:

<?php

namespace Custom\Module\Setup; 
use Magento\Framework\Setup\UpgradeDataInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Eav\Setup\EavSetup; 

class UpgradeData implements UpgradeDataInterface 
{
    public function __construct(
        EavSetup $eavSetupFactory
        ) 
    { 
        $this->eavSetupFactory = $eavSetupFactory; 
    } 

    public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { 
        $setup->startSetup();
        $this->eavSetupFactory->updateAttribute(4,135,'is_used_for_promo_rules',1,null); 
        $setup->endSetup(); 
    } 

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.