Showing posts with label Magento Fetch Records. Show all posts
Showing posts with label Magento Fetch Records. Show all posts

Friday, September 13, 2013

Reindexing of Product Flat Data in magento:

You have to truncate all the 'catalog_product_flat_i' table:
where 'i' can be 1,2,3,4,....

In my case there are 3 table so i fire this query to my phpmyadmin:
TRUNCATE `catalog_product_flat_1`;
TRUNCATE `catalog_product_flat_2`;
TRUNCATE `catalog_product_flat_3`;

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 view recent products in magento?

Magento Recent Product

how to view all brands in magento containing products?

View all brands in magento

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();?>">

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);
}
$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);
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

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);
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

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();
//(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’)