I am trying to check if two conditions are true in the Magento category view file. Specifically if parent id = 1 and if category name = Nike.

Can someone please suggest how I can update the code below to get this working?

<?php if ($_category->getParentCategory()->getId() == 1) && ($_category->getName() == 'Nike'): ?>
    <p>Then show this</p> 
<?php endif; ?>
  • 2
    Please don't use this kind of fix. Create an attribute of category and on that attribute apply condition which show and hide your div or functionality. Oct 17, 2017 at 9:40

1 Answer 1


Your if condition syntax is wrong. You use

if ($_category->getParentCategory()->getId() == 1) && ($_category->getName() == 'Nike'):

In this code, your if statement parenthesis ends before && operator.

The correct syntax is :

if ($_category->getParentCategory()->getId() == 1 && $_category->getName() == 'Nike'):

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.