Exemple #1
0
 /**
  * Set collection to pager
  *
  * @param Varien_Data_Collection $collection
  * @return Mage_Catalog_Block_Product_List_Toolbar
  */
 public function setCollection($collection)
 {
     $this->_collection = $collection;
     $this->_collection->setCurPage($this->getCurrentPage());
     // we need to set pagination only if passed value integer and more that 0
     $limit = (int) $this->getLimit();
     if ($limit) {
         $this->_collection->setPageSize($limit);
     }
     if ($this->getCurrentOrder() && $this->getRequest()->getParam('order')) {
         if ($this->getCurrentOrder() == 'new' && Mage::registry('current_category')) {
             $this->_collection->setOrder('entity_id', 'desc');
         } else {
             if ($this->getCurrentOrder() == 'popular' && Mage::registry('current_category')) {
                 $this->getCollection()->getSelect()->joinLeft(array('sfoi' => $collection->getResource()->getTable('sales/order_item')), 'e.entity_id = sfoi.product_id', array('qty_ordered' => 'SUM(sfoi.qty_ordered)'))->group('e.entity_id')->order('qty_ordered ' . $this->getCurrentDirection());
             } else {
                 if ($this->getCurrentOrder() == 'price' && Mage::registry('current_category')) {
                     $this->_collection->setOrder($this->getCurrentOrder(), $this->getCurrentDirection());
                 } else {
                     $this->_collection->setOrder('position', 'asc');
                 }
             }
         }
     } else {
         if (Mage::registry('current_category')) {
             $this->_collection->setOrder('position', 'asc');
         }
     }
     return $this;
 }
Exemple #2
0
 /**
  * Set collection to pager
  *
  * @param Varien_Data_Collection $collection
  * @return Mage_Catalog_Block_Product_List_Toolbar
  */
 public function setCollection($collection)
 {
     $this->_collection = $collection;
     $this->_collection->setCurPage($this->getCurrentPage());
     // we need to set pagination only if passed value integer and more that 0
     $limit = (int) $this->getLimit();
     if ($limit) {
         $this->_collection->setPageSize($limit);
     }
     if ($this->getCurrentOrder()) {
         $this->_collection->setOrder($this->getCurrentOrder(), $this->getCurrentDirection());
     }
     return $this;
 }
 /**
  * Set collection to pager
  *
  * @param Varien_Data_Collection $collection
  * @return Mage_Catalog_Block_Product_List_Toolbar
  */
 public function setCollection($collection)
 {
     $this->_collection = $collection;
     $this->_collection->setCurPage($this->getCurrentPage());
     // we need to set pagination only if passed value integer and more that 0
     $limit = (int) $this->getLimit();
     if ($limit) {
         $this->_collection->setPageSize($limit);
     }
     if ($this->getCurrentOrder()) {
         $this->_collection->setOrder(array($this->getCurrentOrder(), 'entity_id'), $this->getCurrentDirection());
         //Ashwani Bhasin 1-29-2012 added entity id
     }
     return $this;
 }
Exemple #4
0
 /**
  * Set collection to pager
  *
  * @param Varien_Data_Collection $collection
  * @return Mage_Catalog_Block_Product_List_Toolbar
  */
 public function setCollection($collection)
 {
     $this->_collection = $collection;
     $this->_collection->setCurPage($this->getCurrentPage());
     // we need to set pagination only if passed value integer and more that 0
     $limit = (int) $this->getLimit();
     if ($limit) {
         $this->_collection->setPageSize($limit);
     }
     //appstockus changed
     if ($this->getCurrentOrder()) {
         $this->_collection->setOrder($this->getCurrentOrder(), $this->getCurrentDirection())->setOrder('price', 'desc');
     }
     // if($this->getCurrentOrder() == 'discount'){
     //     $this->getCollection()->getSelect()->joinLeft('catalog_product_index_price as cpd','e.entity_id = cpd.entity_id','SUM(cpd.price - cpd.final_price) AS discount')->group('e.entity_id')->order('<strong class="StrictlyAutoTagBold">discount</strong> desc');
     // } else if ($this->getCurrentOrder()) {
     //     $this->_collection->setOrder($this->getCurrentOrder(), $this->getCurrentDirection())->setOrder('price', 'desc');
     // }
     return $this;
 }