Reputation: 81
I want to add some new category attributes along with a new category attribute group to group them all under.
The upgrade is being ran with no errors but it doesn't seem to run the code even though it looks perfect to me. Am I missing something?
UpgradeData.php
class UpgradeData implements UpgradeDataInterface
{
private $eavSetupFactory;
public function __construct(EavSetupFactory $eavSetupFactory) {
$this->eavSetupFactory = $eavSetupFactory;
}
public function upgrade(ModuleDataSetupInterface $setup,ModuleContextInterface $context)
{
$setup->startSetup();
if (version_compare($context->getVersion(), '1.0.4', '<')) {
$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
$eavSetup->addAttributeGroup(
Category::ENTITY,
$eavSetup->getDefaultAttributeSetId(Category::ENTITY),
'Thirdlight Settings',
99
);
$eavSetup->addAttribute(\Magento\Catalog\Model\Category::ENTITY, 'thirdlight_banner', [
'type' => 'string',
'label' => 'Thirdlight Banner',
'input' => 'text',
'source' => '',
'visible' => true,
'default' => '',
'required' => false,
'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
'group' => 'Thirdlight Settings',
]);
$setup->endSetup();
}
Module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Avery_Orderattribs" setup_version="1.0.4">
<sequence>
<module name="Magento_Sales"/>
</sequence>
</module>
</config>
Upvotes: 1
Views: 1587
Reputation: 78
Did you check if your module data_version
column is update to 1.0.4 in your setup_module
database table?
Upvotes: 1