I want to hide the payment logos for 1 product category. I've taken a look and they're in a block in the local.xml, but as far as I know XML doesn't like if statements.

Is there any way of doing it on PHP?


You can use the Custom Layout Update field in the Custom Design tab when editing a category if you want to add custom XML.

If you want to keep this in your local.xml, the category controller loads a handle called CATEGORY_ followed by the category ID. So you could basically do the following:

   <reference name="left">
        ...remove my icon...
  • Is the category ID the numeric one? – VDD Jun 3 '15 at 13:30
  • Yes that would be the one. If you edit a category, you will see the title is "CATEGORY_NAME (ID: CATEGORY_ID)" – Mayers Jun 3 '15 at 13:32
  • so would it look like <category_17>? – VDD Jun 3 '15 at 13:51
  • That would be <CATEGORY_17>, capitalized. – Mayers Jun 3 '15 at 14:02

The quickest and easiet way in PHP is to check the product category, Say that the category name is 'cat1' so, your block will look like this:

$product = Mage::getModel('catalog/product')->load($productId);

$cats = $product->getCategoryIds();
foreach ($cats as $category_id) :
    $_cat = Mage::getModel('catalog/category')->load($category_id) ;
if ($cat->getName()==="cat1"):

// Set div style=display:none to hide it
div class="payment-logos" style="display:none !important;"

endif; // End if
endforeach; // End foreach

Have fun !!

  • Loading objects unnecessarily will slow down a store in no time. To avoid. – Mayers Jun 3 '15 at 14:01

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.