0
특정 상위 카테고리의 베스트 셀러/베스트 셀러를 자홍으로 표시하고 싶습니다. 꽃, 케이크 등 부모 카테고리가 있습니다. 꽃에 갈 때는 케이크에서 꽃을 피우고 케이크에서 가장 잘 팔리는 제품을 보여주고 싶습니다.특정 카테고리의 최고 판매 상품을 표시하는 방법 magento
특정 상위 카테고리의 베스트 셀러/베스트 셀러를 자홍으로 표시하고 싶습니다. 꽃, 케이크 등 부모 카테고리가 있습니다. 꽃에 갈 때는 케이크에서 꽃을 피우고 케이크에서 가장 잘 팔리는 제품을 보여주고 싶습니다.특정 카테고리의 최고 판매 상품을 표시하는 방법 magento
Use following code:- public function getBestSellersCollection($numDays = 60, $categoryId) { $todayDate = Mage::getModel('core/date')->date('Y-m-d'); $fromDate = date('Y-m-d', strtotime('now -'.$numDays.' days')); $_bestSellersCollection = Mage::getResourceModel('reports/product_collection') ->addOrderedQty() ->setStoreId($storeId) ->addAttributeToSelect('name') ->addAttributeToSelect('entity_id') ->addAttributeToSelect('url_path') ->addCategoryFilter($categoryId) ->addAttributeToFilter('created_at', array('date' => true, 'from' => $fromDate, 'to' => $todayDate)) ->setOrder('ordered_qty', 'desc'); $bestsoldids = Array(); foreach($_bestSellersCollection as $col){ $bestsoldids[] = $col->getData('entity_id'); } return $bestsoldids; }
사용이 링크 : http://blog.chapagain.com.np/magento-get-bestselling-products-by-category-and-date-time/ –