Hello
Here Qurery for Create Most View product of current product of categories
This Section Query used Most view Product view in magento. it's difficult to get because
I am seaching but to get proper result. after i get solution from different different reference
site. i am will give proper guide for that. it success to use it.
$storeId = Mage::app()->getStore()->getId();
$category_ids = $_product->getCategoryIds();
/** date range product view count */
$fromDate=date('Y-m-d',strtotime("yesterday"));
$toDate = now();
$product_id = Mage::registry('current_product')->getId();
$products = Mage::getResourceModel('reports/product_collection')
->addAttributeToSelect('*')
->addViewsCount()
->joinField('category_id',
'catalog/category_product',
'category_id',
'product_id=entity_id',
null,
'left'
)
->setStoreId($storeId)
->addStoreFilter($storeId)
->setPageSize(5)//set the pae size
->addAttributeToFilter('category_id', array('in' => $category_ids ));
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products);
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($products);
here one problem you face if current product detail page in this section then you have
I have issue when I go to section on product detail page; the current product is also getting displayed on this. I just need to remove the current product from section.
it's soultion is that without change query
foreach($products as $_item){
$myid = $_item->getId();
if ($myid != $product_id ){
<?php echo $_item->getProductUrl() ?>
}
}
Here Qurery for Create Most View product of current product of categories
This Section Query used Most view Product view in magento. it's difficult to get because
I am seaching but to get proper result. after i get solution from different different reference
site. i am will give proper guide for that. it success to use it.
$storeId = Mage::app()->getStore()->getId();
$category_ids = $_product->getCategoryIds();
/** date range product view count */
$fromDate=date('Y-m-d',strtotime("yesterday"));
$toDate = now();
$product_id = Mage::registry('current_product')->getId();
$products = Mage::getResourceModel('reports/product_collection')
->addAttributeToSelect('*')
->addViewsCount()
->joinField('category_id',
'catalog/category_product',
'category_id',
'product_id=entity_id',
null,
'left'
)
->setStoreId($storeId)
->addStoreFilter($storeId)
->setPageSize(5)//set the pae size
->addAttributeToFilter('category_id', array('in' => $category_ids ));
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products);
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($products);
here one problem you face if current product detail page in this section then you have
I have issue when I go to section on product detail page; the current product is also getting displayed on this. I just need to remove the current product from section.
it's soultion is that without change query
foreach($products as $_item){
$myid = $_item->getId();
if ($myid != $product_id ){
<?php echo $_item->getProductUrl() ?>
}
}
No comments:
Post a Comment
Thank You For Comment