I want to display "it working" on default.phtml if the product is assigned to attribute [Franke] with "yes".

Please help. I have tried the below code, but it doesn't work

getProduct()->getAttributeText('Franke') == "Yes") {
echo "It working";
} else {
echo "It not working";
  • @JasvirSingh Thanks for responds. it not working, it crash everything
    – Bayzel
    Jun 17, 2022 at 8:55
  • try like this: if($getProduct->getAttributeText('phone') == __('Yes')) Jun 17, 2022 at 8:56
  • this code <?php if($getProduct->getAttributeText('franke') == __('Yes')) : ?> <? echo "<p style='color: #07f5471; font-weight: bold;'>" . "It working" . "</p>" ; ?> <?php endif;?> it doesn't work
    – Bayzel
    Jun 17, 2022 at 9:02
  • First issue is solved or not? And for this one check that 'franke' attribute is of type yes/no. Jun 17, 2022 at 9:04
  • ohk let try something different @JasvirSingh let say you have category of special and you want show it working if a product is from category special
    – Bayzel
    Jun 17, 2022 at 9:17

1 Answer 1


Based on tags I guess you have an issue with loading product data on checkout cart page and let me explain 2 possible way to solve

Magento loads restricted attribute list for category collection or quote (cart) collection

1. Add your attribute to load in cart

In your custom extension create config file catalog_attributes.xml


<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    <group name="quote_item">
        <attribute name="franke"/>

Don't forget to flush cache, etc. After you can receive this data from product. In case you have a boolean attribute better to check like:

<?php if ($product->getData('franke') === '1'): ?>
<?php else: ?>
<?php endif; ?>

2. Load raw attribute data from product (worst in key of performance)

$franke = $product->getResource()->getAttributeRawValue($product->getId(), 'franke', $product->getStoreId());
// check ($franke === '1')
  • 1
    Thank you it working perfectly
    – Bayzel
    Jun 17, 2022 at 9:36
  • Why you downvote answer which helped you? If you found the solution please don't forget to mark your question as answered. BR Jun 17, 2022 at 10:02
  • sorry but i didn't downvote anything, sorry if i missed something . i'm new here so i'm still learning things.
    – Bayzel
    Jun 17, 2022 at 11:36

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.