Last active
May 18, 2018 15:57
-
-
Save aleron75/7304592 to your computer and use it in GitHub Desktop.
Programmaticalli create a Yes/No Magento Category Attribute
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** @var Mage_Eav_Model_Entity_Setup $installer */ | |
$installer = $this; | |
$installer->startSetup(); | |
$this->addAttribute( | |
'catalog_category', | |
'my_custom_attribute', | |
array( | |
'group' => 'General Information', | |
'input' => 'select', | |
'type' => 'int', | |
'source' => 'eav/entity_attribute_source_boolean', | |
'label' => 'My Custom Attribute', | |
'required' => 0, | |
'unique' => 0, | |
'sort_order' => 3, | |
'user_defined' => 1, | |
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, | |
)); | |
$installer->endSetup(); |
@rafiqeladli like this:
/* @var $collection Mage_Catalog_Model_Resource_Category_Collection */
$collection = Mage::getResourceModel('catalog/category_collection');
$collection->addAttributeToFilter(
'my_custom_attribute' // <!-- Change this to your actual category attribute
'1' // Supplying "0" would filter by categories set to "no" instead"
);
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks!