Advertisement
Guest User

Untitled

a guest
Sep 30th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. class Featured extends MagentoCatalogBlockProductListProduct
  2. {
  3. protected $categoryFactory;
  4.  
  5. public function __construct(
  6. MagentoCatalogBlockProductContext $context,
  7. MagentoCatalogModelCategoryFactory $categoryFactory,
  8. array $data = []
  9. ) {
  10. $this->categoryFactory = $categoryFactory;
  11. parent::__construct(
  12. $context,
  13. $data
  14. );
  15. }
  16.  
  17. public function getCategoryProductsAscZeroLast($categoryId)
  18. {
  19. $products = $this->categoryFactory->create()->load($id)->getProductCollection()->addAttributeToSelect('*');
  20. //$products->getSelect()->setOrder('cat_index_position', 'DESC');
  21. return $products;
  22. }
  23. }
  24.  
  25. public function getCategoryProductsAscZeroLast($categoryId)
  26. {
  27. $products = $this->getCategoryData($categoryId)->getProductCollection();
  28. $products->addAttributeToSelect('*');
  29. $products->getSelect()->order(new Zend_Db_Expr("CASE WHEN `cat_index_position` = '0' THEN 9999 ELSE 1 END"));
  30. return $products;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement