Skip to content

Instantly share code, notes, and snippets.

@wcodex
Created October 2, 2013 17:16
Show Gist options
  • Save wcodex/6797110 to your computer and use it in GitHub Desktop.
Save wcodex/6797110 to your computer and use it in GitHub Desktop.
Display or get new products in Magento store
$allproduct = Mage::getModel('catalog/product')->getCollection()->setOrder('entity_id','desc')->getData();
$_helper = $this->helper('catalog/output');
foreach($allproduct as $product){
echo '<div class="product_box">';
$obj = Mage::getModel('catalog/product');
$productid = $product['entity_id'];
$_product = $obj->load($productid); // Enter your Product Id in $product_id
$productName = $_product->getName();
$productDescription = $_product->getDescription();
$productImage = $_product->getImageUrl();
$productUrl = $_product->getProductUrl();
$productPrice = $_product->getPrice();
$addToCartUrl = Mage::helper('checkout/cart')->getAddUrl($_product);
echo "<h3>";
echo $_product->getName();
echo "</h3>";
echo '<a href="'.$productUrl.'"><img src="'.$productImage.'" alt="Shoes 1" /></a>';
echo '<p>"'.$productDescription.'"</p>';
echo '<p class="product_price">"'.$productPrice.'"</p>';
echo '<a href="'.$productUrl.'" class="detail"></a>';
echo '<a href="'.$addToCartUrl.'" class="addtocart"></a>';
echo '</div>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment