0

I am working on magento 1.9.2 RWD theme and I am trying to display the product additional info via custom attribute.

I have created the attribute - Admin Default Store View faq FAQ

I added a new block FAQ in the layout.xml and it is displaying on the product page.When I am adding an cms block it is displaying properly.

But When I am trying to get the value of faq attribute through admin panel it is giving error and not displying. My code of faq.phtml in the product/view/faq.phtml are as follow-

/**

 * Product description template

 *

 * @see Mage_Catalog_Block_Product_View_Description

 */

?>

<?php 

 $_product = $this->getProduct();

//$pid= $_product->getId();

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

/*  $ids = $_product->getCategoryIds();

 $categoryId = (isset($ids[0]) ? $ids[0] : null); */

?>
 <?php

 if($_product->getFAQ()){ ?>

    <?php echo $_product->getFAQ();?>

 <?php } ?>

I am getting the below Error:

Fatal error: Call to a member function getFAQ() on null in /home/berkowitsclinic/public_html/hairwits.com/app/design/frontend/rwd/default/template/catalog/product/view/faq.phtml on line 107

please help.

0

Login you admin Catalog->attribute->Mange attribute select faq

change Used in Product Listing should be Yes

  • Used in product Listing option is YES , still not showing anything. – R K Shrivastaw Oct 31 '17 at 10:38
  • Are you get product data $_product->getData() ?. what your product attribute code? – mohan Oct 31 '17 at 10:55
  • Check you attribute set name – mohan Oct 31 '17 at 11:12
  • Attribute set name is Default - and attribute code is faq & importantly faq attribute is visible in admin panel Catalogue > manage Product > Faq – R K Shrivastaw Nov 2 '17 at 7:56
  • Assign some values in and try $_product->getFaq(); – mohan Nov 2 '17 at 8:13
0

Which type of attribute you are created? is it dropdown or multiselect ? if Yes then above code should work but if you have text type attribute then try to call by below code....

<?php

         if($_product->getFAQ()){ ?>

            <?php echo $product->getAttributeText('faq'); ;?>

         <?php } ?>   

and if this is not worked then try to with below code....

<?php

     if($_product->getFAQ()){ ?>

        <?php echo $product->getData('faq');?>

     <?php } ?>
  • I used this code but unfortunately error is not coming but nothing is displaying. Attribute type is test area. – R K Shrivastaw Oct 31 '17 at 7:22
  • I also tried to change the code as it is Text Area but no response-<?php if($_product->getFAQ()){ ?> <?php echo $product->getAttributeTextArea('faq'); ?> <?php } ?> – R K Shrivastaw Oct 31 '17 at 7:41
  • check updated answer,sure it will work and also check settings in admin. – akgola Oct 31 '17 at 7:42
  • @ Akgola in your updated answer - echo echo is 2 times.. when using the same it is giving syntax error - unexpected 'echo' (T_ECHO) and when using single echo nothing is displayed. – R K Shrivastaw Oct 31 '17 at 7:47

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.