1

I would like to create a product's spec table on my product's page.

In the admin I have created:

Attributeset -> Motherboards

Attributegroup -> Memory (My table header)

Attributes -> Supported Memory Types Memory Slots

For the products, I have set these values in the admin part.

Now I want to create a table on the product page. I'm very new to Magento and i'm unsure whether I have to write a module for it, or use Magento's build in function.

Can somebody tell me which direction I should follow on this?

1 Answer 1

0

You'll probably want to build your own to get exactly what you want. I had to do something similar on a site. We had multiple groups that had to be displayed this way so we named the Attribute Groups "TBL GROUPNAME" where TBL was our key that it should be output in this manner. I trimmed out a lot of code in this, but the relevant code in my block was this code below. It loops those attribute groups and creates an array that we can output in the template file.

$groups = Mage::getModel('eav/entity_attribute_group')->getCollection()
     ->addFieldToFilter('attribute_set_id', array('eq' => $_product->getAttributeSetId()))
     ->addFieldToFilter('attribute_group_name', array('like' => '%TBL %'));

 foreach($groups as $group){    
     $attributes[$group->getId()] = array("name"=>$group->getAttributeGroupName(), "values"=>array());

     foreach($_product->getAttributes($group->getId()) as $attribute) {
         $val = trim($attribute->getFrontend()->getValue($child));

         $attributes[$group->getId()]['values'][] = array("name"=>$attribute->getFrontendLabel(), "value"=>$val);
     }
 }
1
  • Thank you very much for your answer. It helped a lot. With that code, i have it all working now! :) Commented Nov 10, 2015 at 22:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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