Important operatinol functions of Magento

1.How to get the category url in magento
<?php echo Mage::getModel('catalog/category')->load($catId)->getUrl() ?>
2.How to remove .html at the end of the url in magento
System => Configuration => Catalog => Search Engine Optimization and empty the fields "Product URL Suffix" and "Category URL Suffix"
3.How to get category’s Thumbnail image in magento
<?php $thumbnail=Mage::getModel('catalog/category')->load($categoryId)->getThumbnail();  //$category_Id -category id ,$thumbnail – image name
if($thumbnail !=''){
$imgPath = Mage::getBaseUrl('media').'catalog/category/'  // Get category image path
echo '';
?>
4.How to get Customer Details By Session
<?php  $customer = Mage::getSingleton('customer/session')->getCustomer();
    print_r($customer);?>
4.1How to get Customer Details By E-Mail
<?php   $customer = Mage::getModel('customer/customer')->loadByEmail(example@mail.com);
    print_r($customer); ?>
5.How to delete product by sku :-
<?php  $product = Mage::getModel('catalog/product');
   $productId = intval($product2->getIdBySku('putSkuHere');
   $product->load($productId)->delete(); ?>
6.How to get module table :-
<?php  
$resource = Mage::getSingleton('core/resource');
$tableName = $resource->getTableName('mymodule/mymodel') 
?>

No comments:

Post a Comment