Get Configurable Super Attributes

I wanted to do a check on a configurable product to see if it had a specific attribute. But not just any attribute, a global attribute used to create associated products within the configurable product – a “Super Product Attribute”. So here ya go:

    $_product = $this->getProduct();
    $_attributes = $_product->getTypeInstance(true)->getConfigurableAttributes($_product);
    foreach($_attributes as $_attribute){

A little bonus:

The “->debug()” method returns the set of values you can use the get magic method on. For example:

  'product_super_attribute_id' => string '263' (length=3)
  'product_id' => string '27' (length=2)
  'attribute_id' => string '80' (length=2)
  'position' => string '0' (length=1)
  'product_attribute (Mage_Catalog_Model_Resource_Eav_Attribute)' => 
      'attribute_id' => string '80' (length=2)
      'entity_type_id' => string '4' (length=1)
      'attribute_code' => string 'color' (length=5)

So var_dump($_attribute->getAttributeId()); will return string ’80’ (length=2). Just use “get” with the Capitalized Label, getProductAttribute(), getProductId(), getPosition(), etc. Enjoy!

Share it


Related Posts

Google and Yahoo Have New Requirements for Email Senders

What ROAS Really Means

Everything You Need to Know About Updating to Google Analytics 4

Contact Us