0

I'm currently displaying a block that has a custom attribute for simple products. But, I don't want to display it for grouped products, only for simple products.

In Manage Products > Custom Attribute I set everything to be blank for just that attribute. I would like Magento to not show the custom attribute tab if the setting is blank or 0.

Perhaps it could be an If statement and hook a display none tag to it? Here is the line I'm looking at that might be useful

<?php if ($attributeValue === 'No' || strpos($_data['code'], '(dv)')) continue; ?>

Thanks in advance!

1

You can try something like this:

if (!$product->getAttributeText('attribute_name') ||
    $product->getAttributeText('attribute_name') == Mage::helper('catalog')->__('No')
) {
    ...
}
0

The layout file catalog.xml provides you with custom handles for every type of product type.

The one you're looking for is PRODUCT_TYPE_simple. This should allow you to do something like

<PRODUCT_TYPE_simple>
   <reference name="product.info">
      <block type="yourcustom/block" name="custom_attributes" template="yourcustom/block.phtml"/>
   </reference>
</PRODUCT_TYPE_simple>

and call that block from the catalog/product/view.phtml or where ever you want to call it from.

  • great I think this is the way to go, how can I call the block now once I've added it in the catalog.xml? – diz0pe Sep 30 '13 at 20:40
  • you can call the block by adding echo $this->getChildHtml('custom_attributes'); in the reference block – Sander Mangel Sep 30 '13 at 21:02
  • Still no luck. I added this to catalog.xml <PRODUCT_TYPE_simple> <reference name="product.info"> <block type="catalog/product_view_type_simple" name="custom_attributes" template="catalog/product/view/type/simple.phtml"/> </reference> </PRODUCT_TYPE_simple> and then called teh block with the getChildHtml on the catalog.phtml – diz0pe Sep 30 '13 at 21:15
  • I'm not familiar with that phtml but find the <block> tag that uses that file as as a template and then use it's name as the name for the <reference> block – Sander Mangel Sep 30 '13 at 21:20
  • this is from the default layout... all I did was change default.phtml to simple.phtml – diz0pe Sep 30 '13 at 21:46

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.