Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $collectionWithRank = Mage::getResourceModel('catalog/product_collection')
- ->addCategoryFilter($cat_data)
- ->addAttributeToSelect('*')
- ->addAttributeToFilter('sort', ['neq' => ''])
- ->addAttributeToSort('sort', 'asc')
- ->addAttributeToSort('entity_id','desc');
- $collectionWithRank->load();
- $collectionWithoutRank = Mage::getResourceModel('catalog/product_collection')
- ->addCategoryFilter($cat_data)
- // ->addAttributeToSelect(array('name', 'price', 'image', 'collect', 'url_key', 'sort'))
- ->addAttributeToSelect('*')
- ->addAttributeToFilter('sort', ['null' => true])
- ->addAttributeToSort('created_at', 'desc')
- ->addAttributeToSort('entity_id','desc');
- $collectionWithoutRank->load();
- $merged_ids = array_merge($collectionWithRankids, $collectionWithoutRankids);
- $collection = Mage::getResourceModel('catalog/product_collection')
- ->addFieldToFilter('entity_id', array('in' => $merged_ids))
- ->addAttributeToSelect('*');
- $collection->getSelect()->order(new Zend_Db_Expr('FIELD(e.entity_id, ' . implode(',', $merged_ids).')'));
- if($sortby = "price_h_to_l"){
- $collection->getSelect()->reset(Zend_Db_Select::ORDER);
- $collection->addAttributeToSort('price', 'desc');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement