Created
July 10, 2023 11:16
-
-
Save magefast/98d27a8170f2d73f59cb922c1525a283 to your computer and use it in GitHub Desktop.
Magento1. Check Attribute in Attributes Set.
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
| <pre> | |
| <?php | |
| error_reporting(E_ALL); | |
| ini_set('display_errors', 1); | |
| require_once './app/Mage.php'; | |
| Mage::app(); | |
| $needAttribute = 'xxx'; | |
| $attributeSetArray = []; | |
| $sets = Mage::getResourceModel('eav/entity_attribute_set_collection') | |
| ->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId()) | |
| ->load() | |
| ->toOptionHash(); | |
| foreach ($sets as $key => $value) { | |
| $attributesInSet = []; | |
| foreach (Mage::getResourceModel('catalog/product_attribute_collection') | |
| ->setAttributeSetFilter($key) as $attribute) { | |
| $attributesInSet[$attribute->getData('attribute_code')] = $attribute->getData('attribute_code'); | |
| } | |
| if (!isset($attributesInSet[$needAttribute])) { | |
| $attributeSetArray[$value] = $key; | |
| } | |
| } | |
| unset($sets); | |
| var_dump($attributeSetArray); | |
| die('---'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment