Snippets with the tag: sku

Get product type from product SKU

Description

Get product type from product SKU

Code

$product = Mage::getModel('catalog/product')->loadByAttribute('sku',$product_sku);
$productType = $product->getTypeId();

Get products data in cart

Description

Display products data in cart

Code

$items = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();

foreach($items as $item) {
        echo 'ID: '.$item->getProductId().'<br />';
        echo 'Name: '.$item->getName().'<br />';
        echo 'Sku: '.$item->getSku().'<br />';
        echo 'Quantity: '.$item->getQty().'<br />';
        echo 'Price: '.$item->getPrice().'<br />';
        echo "<br />";
}

Get product stock quantity by sku

Description

Get product stock quantity by sku

Code

$sku = "AB123456789";
$_product = Mage::getModel('catalog/product')->loadByAttribute('sku', $sku);

$stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product);

print_r($stock->getData());

echo $stock->getQty();
echo $stock->getMinQty();
echo $stock->getMinSaleQty();