Research and Development work on PHP, MYSQ,JQuery,Angular Js,React Native,Laravel,Wordpress,Magento,Joomla
Sunday, July 8, 2012
how to display all countries in magento ?
$countryList = Mage::getResourceModel('directory/country_collection')->loadData()->toOptionArray(false); print_r( $countryList);
how to fetch all states of country in magento?
$countryList = Mage::getResourceModel('directory/country_collection') ->loadData() ->toOptionArray(false);
$regionCollection = Mage::getModel('directory/region') ->getResourceCollection() ->addCountryFilter('IN')->load();
how to check home page in magento?
if(Mage::getSingleton('cms/page')->getIdentifier() == 'home' &&Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms' )
How to view recent sold product of current category in magento?
load(3);
$_productCollection = $cats->getProductCollection() ->addAttributeToFilter('visibility',4);
$intNumRecord = Mage::getStoreConfig('banner/carousel_configuration/bestseller_number_product');
$_productCollection = $_productCollection ->setPageSize($intNumRecord);
if($_productCollection->count()) { ?>
load($_products->getId());?>
how to view popular products in magento? or maximum sold products in store
getStore()->getStoreId(); $this->_productCollection = Mage::getResourceModel('reports/product_collection');
if ($this->getTimeLimit())
{
$product = Mage::getModel('catalog/product');
$todayDate = $product->getResource()->formatDate(time());
$startDate = $product->getResource() ->formatDate(time() - 60 * 60 * 24 * $this ->getTimeLimit());
$this->_productCollection = $this->_productCollection ->addOrderedQty($startDate, $todayDate);
}
else
{
$this->_productCollection = $this->_productCollection ->addOrderedQty();
}
$intNumRecord = Mage::getStoreConfig('banner/carousel_configuration/bestseller_number_product');
$this->_productCollection = $this->_productCollection ->addAttributeToSelect('*') ->setStoreId($storeId) ->addStoreFilter($storeId) ->setOrder('ordered_qty', 'desc') ->setPageSize($intNumRecord);
$_productCollection = $this->_productCollection ->setPageSize($intNumRecord);
if($_productCollection->count())
{ ?>
load($_products->getId());?>getShortDescription();if(strlen($strproductdescription)>82) $strproductdescription = trim(substr($strproductdescription,0,81)."...");$strProductName = $_product->getName(); ?> 22){$strProductName = substr($strProductName,0,21)."...";}?>
<a href="getProductUrl() ?>" title="stripTags($_product->getName(), null, true) ?>">
<a href="getUrl('popular-products');?>">__('More...');?>
How to display add to cart url on any page on magento?
<?php if(isSaleable()): ?>
<button type="button" title="__(‘Add to Cart’) ?>” class=”button btn-cart” onclick=”setLocation(‘getLayout()->createBlock(‘catalog/product_list’)->getAddToCartUrl($objProduct) ?>’)”>__(‘Add to Cart’) ?>
__(‘Out of stock’) ?>
How to display total reviews of product in magento?
$intTotalReviewPerProduct = $objCategoryBanners->fnGetTotalProductReview($_product);
How to display image of current product on magento?
<a href="getProductUrl();?>">
<img src="helper('catalog/image')->init($objProduct, 'small_image')->resize(60,110); ?>" alt="getName();?>">
<img src="helper('catalog/image')->init($objProduct, 'small_image')->resize(60,110); ?>" alt="getName();?>">
How to display total reviews of product in magento?
$intTotalReviewPerProduct = $objCategoryBanners->fnGetTotalProductReview($_product);
How to display average ratings of product in magento?
public function fnGetTotalProductReview($objCurrentProduct)
{
$objReview = Mage::getModel('review/review');
return $objReview ->getTotalReviews($objCurrentProduct->getId(),true);
}
{
$objReview = Mage::getModel('review/review');
return $objReview ->getTotalReviews($objCurrentProduct->getId(),true);
}
$intTotalReviewPerProduct = fnGetTotalProductReview($_product);
if($intTotalReviewPerProduct > 0){echo $this ->getLayout() ->createBlock('catalog/product_list') ->getReviewsSummaryHtml($_product);
}
}
How to show all the manufactures or brand list in magento?
$product = Mage::getModel('catalog/product');
$attributes = Mage::getResourceModel('eav/entity_attribute_collection')
->setEntityTypeFilter($product->getResource()->getTypeId())
->addFieldToFilter('attribute_code', 'manufacturer');
$attribute = $attributes->getFirstItem()->setEntity($product->getResource());
$manufacturers = $attribute->getSource()->getAllOptions(false);
$attributes = Mage::getResourceModel('eav/entity_attribute_collection')
->setEntityTypeFilter($product->getResource()->getTypeId())
->addFieldToFilter('attribute_code', 'manufacturer');
$attribute = $attributes->getFirstItem()->setEntity($product->getResource());
$manufacturers = $attribute->getSource()->getAllOptions(false);
foreach ($manufacturers as $manufacturer)
{
echo Mage::getBaseUrl(); ?>catalogsearch/advanced/result/?manufacturer[]=$manufacturer['value']
echo Mage::getBaseUrl(); ?>catalogsearch/advanced/result/?manufacturer[]=$manufacturer['label']
}
How to get the customer login, logout, register and checkout url?
Mage::getUrl('customer/account/login'); //login url
Mage::getUrl('customer/account/logout'); //logout url
Mage::getUrl('customer/account'); //My Account url
Mage::getUrl('customer/account/create'); // Register url
Mage::getUrl('checkout/cart'); //Checkout url
Mage::getUrl('customer/account/logout'); //logout url
Mage::getUrl('customer/account'); //My Account url
Mage::getUrl('customer/account/create'); // Register url
Mage::getUrl('checkout/cart'); //Checkout url
How to show all the manufactures or brand list in magento?
$product = Mage::getModel('catalog/product');
$attributes = Mage::getResourceModel('eav/entity_attribute_collection')
->setEntityTypeFilter($product->getResource()->getTypeId())
->addFieldToFilter('attribute_code', 'manufacturer');
$attribute = $attributes->getFirstItem()->setEntity($product->getResource());
$manufacturers = $attribute->getSource()->getAllOptions(false);
$attributes = Mage::getResourceModel('eav/entity_attribute_collection')
->setEntityTypeFilter($product->getResource()->getTypeId())
->addFieldToFilter('attribute_code', 'manufacturer');
$attribute = $attributes->getFirstItem()->setEntity($product->getResource());
$manufacturers = $attribute->getSource()->getAllOptions(false);
foreach ($manufacturers as $manufacturer)
{
echo Mage::getBaseUrl(); ?>catalogsearch/advanced/result/?manufacturer[]=$manufacturer['value']
echo Mage::getBaseUrl(); ?>catalogsearch/advanced/result/?manufacturer[]=$manufacturer['label']
}
How to get the customer login, logout, register and checkout url?
Mage::getUrl('customer/account/login'); //login url
Mage::getUrl('customer/account/logout'); //logout url
Mage::getUrl('customer/account'); //My Account url
Mage::getUrl('customer/account/create'); // Register url
Mage::getUrl('checkout/cart'); //Checkout url
Mage::getUrl('customer/account/logout'); //logout url
Mage::getUrl('customer/account'); //My Account url
Mage::getUrl('customer/account/create'); // Register url
Mage::getUrl('checkout/cart'); //Checkout url
set or get magento session
//Setting session
Mage::getSingleton('core/session')->setMySessionVariable('value');
//Getting session
Mage::getSingleton('core/session')->getMyDesignProductVariable()
//Unset session
Mage::getSingleton('core/session')->setTestingMagento();
Mage::getSingleton('core/session')->setMySessionVariable('value');
//Getting session
Mage::getSingleton('core/session')->getMyDesignProductVariable()
//Unset session
Mage::getSingleton('core/session')->setTestingMagento();
//(Use customer or core session in frontend. Use adminhtml session in the backend.)
Core Session:- Mage::getSingleton(‘core/session’)
Customer Session:- Mage::getSingleton(‘customer/session’)
Admin Session:- Mage::getSingleton(‘adminhtml/session’)
Core Session:- Mage::getSingleton(‘core/session’)
Customer Session:- Mage::getSingleton(‘customer/session’)
Admin Session:- Mage::getSingleton(‘adminhtml/session’)
How to get cms content from cms id in magento?
$objCmsPage = Mage::getModel('cms/page')->getCollection()->addFieldToFilter('identifier','next-day');
foreach($objCmsPage as $objCmsPageContent)
{
break;
}
$objCmsHelper = Mage::helper('cms');
$objProcessor = $objCmsHelper->getPageTemplateProcessor();
echo $objProcessor->filter($objCmsPageContent->getContent());
foreach($objCmsPage as $objCmsPageContent)
{
break;
}
$objCmsHelper = Mage::helper('cms');
$objProcessor = $objCmsHelper->getPageTemplateProcessor();
echo $objProcessor->filter($objCmsPageContent->getContent());
How to get cms content from cms id in magento?
$objCmsPage = Mage::getModel('cms/page')->getCollection()->addFieldToFilter('identifier','next-day');
foreach($objCmsPage as $objCmsPageContent)
{
break;
}
$objCmsHelper = Mage::helper('cms');
$objProcessor = $objCmsHelper->getPageTemplateProcessor();
echo $objProcessor->filter($objCmsPageContent->getContent());
foreach($objCmsPage as $objCmsPageContent)
{
break;
}
$objCmsHelper = Mage::helper('cms');
$objProcessor = $objCmsHelper->getPageTemplateProcessor();
echo $objProcessor->filter($objCmsPageContent->getContent());
How To fetch all categories and subcategories in magento?
$_helper = Mage::helper(‘catalog/category’)
$_categories = $_helper->getStoreCategories()
$currentCategory = Mage::registry(‘current_category’)
if (count($_categories) > 0)
{
foreach($_categories as $_category)
{
echo $_category->getName()
$_category = Mage::getModel(‘catalog/category’)->load($_category->getId())
$_subcategories = $_category->getChildrenCategories()
if (count($_subcategories) > 0)
{
foreach($_subcategories as $_subcategory)
{
echo $_subcategory->getName()
}
}
}
}
$_categories = $_helper->getStoreCategories()
$currentCategory = Mage::registry(‘current_category’)
if (count($_categories) > 0)
{
foreach($_categories as $_category)
{
echo $_category->getName()
$_category = Mage::getModel(‘catalog/category’)->load($_category->getId())
$_subcategories = $_category->getChildrenCategories()
if (count($_subcategories) > 0)
{
foreach($_subcategories as $_subcategory)
{
echo $_subcategory->getName()
}
}
}
}
Subscribe to:
Posts (Atom)