Magento News

 

Get by SKU instead of Product ID

by fRAiLtY (Posted Thu, 25 Mar 2010 13:54:37 GMT)
Hi guys,

I’m currently using this code in a .phtml file

Code:

<?php
    $productId 
$this->getProduct_id();
    
$product Mage::getModel('catalog/product')->load($productId);                                 
?>
    <a href="<?php echo $product->getProductUrl() ?>" >
    £;<?php echo number_format($product->getPrice(),2); ?> 
    

 

This when called via a static block gets a product by ID number and displays it whereever I display the static block. I want to change the variable to SKU, but I can’t figure it out and keep breaking it.

I use this code in the static block:

Code:
{{block type="catalog/product_view" product_id="1" template="catalog/product/matrix.phtml"}}
 

Where matrix.phtml is the first piece of code. How do I change either to do exactly the same thing just by SKU instead of ID?

Cheers



http://magento-forum.co.uk/viewtopic.php?f=3&t=172#p638

Magento Forum

Possibly Related Posts:


 

Leave a Reply