0

I'm trying to show an attribute in product page. I have create my .phtml file with the bellow code.

<?php       
  $_prodID = Mage::registry('current_product')->getId();
  $_product = Mage::getModel('catalog/product')->load($_prodID);
?>

<?php echo $_product->getData('assembly_instructions'); ?>

and I'm calling the block with this code

{{block type="core/template" template="catalog/product/view/attributes/assembly.phtml"}}

The above code loads the info of the attribute but it show's the same info in every product.

Doesn't load different info of each product, loads the info that i will see for the first time and this will be cached.

I have search it here in forum and i have follow this https://stackoverflow.com/questions/13883139/how-to-add-product-attribute-on-product-page-via-cms-block-magento but hasn't help a lot.

Can someone help me with this?

  • I solved similar task few months ago. I need only to remember what I did. Do you mean catalog_product_list page or catalog_product_view ? – zhartaunik Feb 23 '16 at 14:34
  • i think i want the product view. The product page with the product details – ebabis Feb 23 '16 at 14:39
0

Initially I'd recommend do not reinitialize product again. It cause additional time. On product view page product is already initialized and can be reached from Mage::registry('current_product')

You need to verify setting inside attribute edit page:

enter image description here

Set yes for this field. Not sure, you may probably will need to reindex catalog. And then this attribute will be accessible on catalog/product/view page.

$product = Mage::registry('current_product');
echo $product->getYourAttributeName();

Upd.1

Okay. To hide from additional information I can offer next:

/**
 * $excludeAttr is optional array of attribute codes to
 * exclude them from additional data array
 *
 * @param array $excludeAttr
 * @return array
 */
public function getAdditionalData(array $excludeAttr = array())

as you can see there is param $excludeAttr. You just need to transfer your attribute inside this method in template...

/app/design/frontend/base/default/template/catalog/product/view/attributes.phtml

<?php if($_additional = $this->getAdditionalData(array('your_attribute_code'))): ?>
  • Sorry if i didn't understand well, but if i set the option "Visible on Product View page on Front end" then the information it should appear on additional information tab and i don't want that. I want to appear this on custom position – ebabis Feb 23 '16 at 15:20
  • I've updated my post. – zhartaunik Feb 23 '16 at 15:30
  • Thanks for everything but the client changes his mind and he wants the attribute inside the additional information. So the solution was simple thanks again. – ebabis Feb 24 '16 at 10:19
  • Ok, glad to hear that everything is ok. Good luck – zhartaunik Feb 24 '16 at 10:22

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.