0
votes

I am new in Magento 1.7.0.2

I would like to make some custom html divs inside the product's phtml page and to call

1) the product description , 2) another div with product tags and 3) another div with reviews of this specific product. 4) another div which will contain a specific cms page (ask about this product)

Do you know how should I write php inside each div in order to call these specific attributes of a product in Magento 1.7.0.2 ?

Thank you very much

1

1 Answers

1
votes

here i am giving your code to do with your above specification you can set it in to your html

1. Product description

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

echo $_product->getShortDescription(); //product's short description
echo $_product->getDescription(); // product's long description

2. product tags

$model=Mage::getModel('tag/tag');
    $tags= $model->getResourceCollection()
        ->addPopularity()
        ->addStatusFilter($model->getApprovedStatus())
        ->addProductFilter(PRODUCT_ID)
        ->setFlag('relation', true)
        ->addStoreFilter(Mage::app()->getStore()->getId())
        ->setActiveFilter()
        ->load();

    if(isset($tags) && !empty($tags)):
        foreach($tags as $tag):
            echo '<span class="tag">'.$tag->getName().'</span>';
        endforeach;

3. Product Reviews

$productId = $product->getId();
$reviews = Mage::getModel('review/review')
->getResourceCollection()
->addStoreFilter(Mage::app()->getStore()->getId()) 
->addEntityFilter('product', $productId)
->addStatusFilter(Mage_Review_Model_Review::STATUS_APPROVED)
->setDateOrder()
->addRateVotes();

4.contain a specific cms page

I would like to suggest you if you want to display product specific content you can create block for product and in phtml file you can call like below

echo $this->getLayout()->createBlock('cms/block')->setBlockId('your-block-id')->toHtml();

Also you can refer detail page

hope this will sure help you.