0

I have the following setup:

A cms page, the contents of which are showing on the product page. (by calling the cms block in the template phtml file)

I do not want to touch the product page phtml file, so that I can keep my template upgrade safe (I bought the template)

I want to show the product sku number inside the product page in addition to the sku appearing in the section with the other attributes, which is the default.

Since the template already provides the cms block to have content appear near the product pricing, (which is where i want the sku to appear) I figured I'll try to get the sku within a cms block by calling a phtml file inside the cms block.

I have created a phtml file as follows:

app/design/frontend/default/mytheme/template/page/getSku.phtml

And I have placed the following code therein (this supposedly gets the product sku):

<?php
    //get product sku
    echo $_product->getAttributeText('sku');
?>

And I have placed the following in the cms block (calls the phtml file):

{{block type="core/template" template="page/getSuk.phtml"}}

Error: My page is not showing completely, (it seems the page doesn't get fully rendered.)

Thank you.

4

1 に答える 1

0

I found the answer here: Calling an attribute in a CMS block in magento

It involved getting the product model on the phtml page first by using the following:

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

Only then can you access the attributes as follows:

echo $_product->getData('sku')
于 2012-12-16T17:03:00.373 に答える