0

I found a way how to add tabs to magento product view, through XML layouts with add tab, where every tab is actually a one phtml template (So I can set description, and attributes in example and retrieve that templates to show in tabs).

What I would like to do is to show every attribute as one tab. I suppose I should separate my attributes in separate phtml templates, and then call it in xml.

Can someone point me what should the PHP for retrieving attributes be alike? Also how should the XML reference for adding new attribute be alike?

I am using 1.7, and my attributes are normal one.

Thanks in advance.

  • can you explain 'Also how should the xml reference for adding new attribut be alike?' Are you asking how to add a new attribute to be used in products? – ProxiBlue Jan 22 '14 at 3:10
  • Why on earth would you want to put every attribute in its own tab? – benmarks Feb 18 '14 at 16:34
1

To get all the attributes used in/is available for products you can use: (this is all attributes, not those that a product has/in its set)

$productAttributes = Mage::getResourceSingleton('catalog/product')
                ->loadAllAttributes()
                ->getAttributesByCode();
 foreach ($productAttributes as $attribute) {
      if($attribute->getIsVisibleOnFront()) {
          // do something with the attribute
      }

 } 

If you have an active product object, and simply want that products attributes, you can simply use:

$productAttributes = $_product->getAttributes();
| improve this answer | |
  • This is sufficient to answer "Can someone point me what should the PHP for retrieving attributes be alike?", and in combination with creating an attribute_group for each attribute and adding them this will work. – benmarks Feb 18 '14 at 16:35
1

You can create a setup script which grabs all product attribute sets. Iterate through the attributes which belong to each set, create a group for each attribute, and then set the attribute to that group.

Viola, solved. Cannot imagine why you would want to do this though.

| improve this answer | |
0

very short version: As the tabs are part of the product view, we can get the current product via

$product = Mage::registry('product')

then you should be able to get attributes with something like this:

$product->getAttributeText('attributeName')
| improve this answer | |
  • I am not entirely sure this answers the OP's question. He is asking how to get the attributes. Your answer is to get the value for a known attribute code. – ProxiBlue Jan 22 '14 at 2:52

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.