Skip to content

Instantly share code, notes, and snippets.

@magefast
Created July 10, 2023 11:16
Show Gist options
  • Save magefast/98d27a8170f2d73f59cb922c1525a283 to your computer and use it in GitHub Desktop.
Save magefast/98d27a8170f2d73f59cb922c1525a283 to your computer and use it in GitHub Desktop.
Magento1. Check Attribute in Attributes Set.
<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