What I am trying to do is to create a link from the parent URL to preselect some attributes for a configurable product. For example. http://localhost/magento-product/#{attribute_id} = {value}. I want to do this for all products that contains these attributes that requires for example size/color. Is there a dynamically way to do this?

  • Yes.it positionable. Are u using default magento theme – Amit Bera Apr 20 '17 at 16:43
  • Yes, that's what I am using – DanteZ Apr 20 '17 at 21:20

This code tested in Magento


$product = Mage::getModel('catalog/product')->load(875);
if($product->getTypeId() == 'configurable'){
  $type = $product->getTypeInstance(true);
  foreach($type->getConfigurableAttributesAsArray($product) as $attribute){
     echo $attribute['id']."\n"; 
     echo $attribute['attribute_id']."\n"; //attribute id that is in Catalog > Attributes > Manage Attributes    
     foreach($attribute['values'] as $v) 
      echo $v['label']."\n";    //value 
      echo $v['value_index']."\n"; //value id                                                                                                                                                


Then you can use either $attribute['id'] and $v['label'] or $attribute['id'] and $v['value_index']

  • I am sorry for the late reply, what If I got a simple product, and I want to see which super attributes that product have? Like size/color/etc. ? I found out how to find the value id for 'color', 'size' but I wanna see dynamically for each simple product how many attributes of those kind it got and get the value id specific – DanteZ Apr 24 '17 at 5:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.