1) Login to magento admin panel
2 Go to Admin Panel -> System -> Configuration -> Inventory-> Product Stock Options
3) Now click on “Add Minimum Qty” button
4) Set 1 for Minimum Qty and select the groups .
All posts by Pramod T P
Product review page does not show up short description magento
<?php echo Mage::getModel(‘catalog/product’)->load($_product->getId())->getShortDescription() ?>
Fetch the categories associated with the products on listing page magento
<?php
$_productCollection=$this->getLoadedProductCollection();
foreach ($_productCollection as $product):
foreach($product->getCategoryIds() as $category):
$categoryIds[] = $category;
endforeach;
endforeach;
print_r( $categoryIds );
?>
jquery get the height of the div
alert(jQuery(‘.div-class’).height());
Fetch the shipping address of a logged in user magento
<?php
$customer = Mage::getModel(‘customer/session’)->getCustomer();
foreach($customer->getAddressesCollection() as $address) $shiipingAddress[] = $address->getData();
foreach($shiipingAddress as $value) $region[]=$value[‘region_id’];
print_r($region);
?>
How to add a block to .phtml file Magento
<?php echo $this->getLayout()->createBlock(‘mymodule/myblock’)->setTemplate(‘mymodule/myblock.phtml’)->toHtml(); ?>
List all products under a given category on homepage magento
{{block type=”catalog/product_list” name=”home.catalog.product.list” alias=”products_homepage” category_id=”4″ template=”catalog/product/list.phtml”}}
List all products on home page magento
{{block type=”catalog/product_list” name=”home.catalog.product.list” alias=”products_homepage” template=”catalog/product/list.phtml”}}
List new products on home page Magento
{{block type=”catalog/product_new” name=”home.catalog.product.new” alias=”product_homepage” template=”catalog/product/new.phtml”}}
jQuery replace a string
<html>
<head>
<script type=”text/javascript” src=”jquery.js”></script>
</head>
<div id=”divId”>
<iframe src=”http://phpcodez.com” scrolling=”no” frameborder=”0″ style=”border: none; width: 90px; height: 20px; “></iframe>
</div>
<script type=”text/javascript”>
jQuery.noConflict();
jQuery(document).ready(function() {
if(jQuery(“#divId”+” iframe”).attr(‘src’).indexOf(“https”)<=-1) {
var newSrc = jQuery(“#divId”+” iframe”).attr(‘src’).replace(“http”,”https”);
jQuery(“#divId”+” iframe”).attr(‘src’,newSrc);
alert(jQuery(“#divId”+” iframe”).attr(‘src’));
}
});
</script>
</html>
