Produced by Araxis Merge on 2023-11-23 04:31:20 +0000. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | /Users/coca/Documents/www/Porto v4.0.2/Theme Files/Magento 2.x/Porto Theme 4.0.6/app/code/Smartwave/Filterproducts/Block/Home | SaleList.php | 2023-06-14 02:05:51 +0000 |
| 2 | /Users/coca/Documents/www/Porto v4.0.2/Theme Files/Magento 2.x/Porto Theme 4.0.7/app/code/Smartwave/Filterproducts/Block/Home | SaleList.php | 2023-06-14 02:05:51 +0000 |
| Description | Between Files 1 and 2 | |
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 1 | 278 |
| Changed | 0 | 0 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| Whitespace | Consecutive whitespace is treated as a single space |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
| Active line-pairing rules |
No regular expressions were active.
| 1 | <?php | 1 | <?php | |||
| 2 | 2 | |||||
| 3 | namespace Smartwave\Filterproducts\Block\Home; | 3 | namespace Smartwave\Filterproducts\Block\Home; | |||
| 4 | 4 | |||||
| 5 | use Magento\Catalog\Api\CategoryRepositoryInterface; | 5 | use Magento\Catalog\Api\CategoryRepositoryInterface; | |||
| 6 | 6 | |||||
| 7 | class SaleList extends \Magento\Catalog\Block\Product\ListProduct { | 7 | class SaleList extends \Magento\Catalog\Block\Product\ListProduct { | |||
| 8 | 8 | |||||
| 9 | protected $_collection; | 9 | protected $_collection; | |||
| 10 | 10 | |||||
| 11 | protected $categoryRepository; | 11 | protected $categoryRepository; | |||
| 12 | 12 | |||||
| 13 | protected $_resource; | 13 | protected $_resource; | |||
| 14 | 14 | |||||
| 15 | public function __construct( | 15 | public function __construct( | |||
| 16 | \Magento\Catalog\Block\Product\Context $context, | 16 | \Magento\Catalog\Block\Product\Context $context, | |||
| 17 | \Magento\Framework\Data\Helper\PostHelper $postDataHelper, | 17 | \Magento\Framework\Data\Helper\PostHelper $postDataHelper, | |||
| 18 | \Magento\Catalog\Model\Layer\Resolver $layerResolver, | 18 | \Magento\Catalog\Model\Layer\Resolver $layerResolver, | |||
| 19 | CategoryRepositoryInterface $categoryRepository, | 19 | CategoryRepositoryInterface $categoryRepository, | |||
| 20 | \Magento\Framework\Url\Helper\Data $urlHelper, | 20 | \Magento\Framework\Url\Helper\Data $urlHelper, | |||
| 21 | \Magento\Catalog\Model\ResourceModel\Product\Collection $collection, | 21 | \Magento\Catalog\Model\ResourceModel\Product\Collection $collection, | |||
| 22 | \Magento\Framework\App\ResourceConnection $resource, | 22 | \Magento\Framework\App\ResourceConnection $resource, | |||
| 23 | array $data = [] | 23 | array $data = [] | |||
| 24 | ) { | 24 | ) { | |||
| 25 | $this->categoryRepository = $categoryRepository; | 25 | $this->categoryRepository = $categoryRepository; | |||
| 26 | $this->_collection = $collection; | 26 | $this->_collection = $collection; | |||
| 27 | $this->_resource = $resource; | 27 | $this->_resource = $resource; | |||
| 28 | 28 | |||||
| 29 | parent::__construct($context, $postDataHelper, $layerResolver, $categoryRepository, $urlHelper, $data); | 29 | parent::__construct($context, $postDataHelper, $layerResolver, $categoryRepository, $urlHelper, $data); | |||
| 30 | } | 30 | } | |||
| 31 | 31 | |||||
| 32 | protected function _getProductCollection() { | 32 | protected function _getProductCollection() { | |||
| 33 | return $this->getProducts(); | 33 | return $this->getProducts(); | |||
| 34 | } | 34 | } | |||
| 35 | 35 | |||||
| 36 | public function getProducts() { | 36 | public function getProducts() { | |||
| 37 | $count = $this->getProductCount(); | 37 | $count = $this->getProductCount(); | |||
| 38 | $category_id = $this->getData("category_id"); | 38 | $category_id = $this->getData("category_id"); | |||
| 39 | $collection = clone $this->_collection; | 39 | $collection = clone $this->_collection; | |||
| 40 | $collection->clear()->getSelect()->reset(\Magento\Framework\DB\Select::WHERE)->reset(\Magento\Framework\DB\Select::ORDER)->reset(\Magento\Framework\DB\Select::LIMIT_COUNT)->reset(\Magento\Framework\DB\Select::LIMIT_OFFSET)->reset(\Magento\Framework\DB\Select::GROUP); | 40 | $collection->clear()->getSelect()->reset(\Magento\Framework\DB\Select::WHERE)->reset(\Magento\Framework\DB\Select::ORDER)->reset(\Magento\Framework\DB\Select::LIMIT_COUNT)->reset(\Magento\Framework\DB\Select::LIMIT_OFFSET)->reset(\Magento\Framework\DB\Select::GROUP); | |||
| 41 | 41 | |||||
| 42 | if(!$category_id) { | 42 | if(!$category_id) { | |||
| 43 | $category_id = $this->_storeManager->getStore()->getRootCategoryId(); | 43 | $category_id = $this->_storeManager->getStore()->getRootCategoryId(); | |||
| 44 | } | 44 | } | |||
| 45 | $category = $this->categoryRepository->get($category_id); | 45 | $category = $this->categoryRepository->get($category_id); | |||
| 46 | $now = date('Y-m-d'); | 46 | $now = date('Y-m-d'); | |||
| 47 | if(isset($category) && $category) { | 47 | if(isset($category) && $category) { | |||
| 48 | $collection->addMinimalPrice() | 48 | $collection->addMinimalPrice() | |||
| 49 | ->addFinalPrice() | 49 | ->addFinalPrice() | |||
| 50 | ->addTaxPercents() | 50 | ->addTaxPercents() | |||
| 51 | ->addAttributeToSelect('name') | 51 | ->addAttributeToSelect('name') | |||
| 52 | ->addAttributeToSelect('image') | 52 | ->addAttributeToSelect('image') | |||
| 53 | ->addAttributeToSelect('small_image') | 53 | ->addAttributeToSelect('small_image') | |||
| 54 | ->addAttributeToSelect('thumbnail') | 54 | ->addAttributeToSelect('thumbnail') | |||
| 55 | ->addAttributeToSelect('special_from_date') | 55 | ->addAttributeToSelect('special_from_date') | |||
| 56 | ->addAttributeToSelect('special_to_date') | 56 | ->addAttributeToSelect('special_to_date') | |||
| 57 | ->addAttributeToFilter('special_price', ['neq' => '']) | 57 | ->addAttributeToFilter('special_price', ['neq' => '']) | |||
| 58 | ->addCategoryFilter($category) | 58 | ->addCategoryFilter($category) | |||
| 59 | ->addAttributeToFilter( | 59 | ->addAttributeToFilter( | |||
| 60 | 'special_from_date', | 60 | 'special_from_date', | |||
| 61 | ['date' => true, 'to' => $this->getEndOfDayDate()], | 61 | ['date' => true, 'to' => $this->getEndOfDayDate()], | |||
| 62 | 'left') | 62 | 'left') | |||
| 63 | ->addAttributeToFilter( | 63 | ->addAttributeToFilter( | |||
| 64 | 'special_to_date', | 64 | 'special_to_date', | |||
| 65 | [ | 65 | [ | |||
| 66 | 'or' => [ | 66 | 'or' => [ | |||
| 67 | 0 => ['date' => true, 'from' => $this->getStartOfDayDate()], | 67 | 0 => ['date' => true, 'from' => $this->getStartOfDayDate()], | |||
| 68 | 1 => ['is' => new \Zend_Db_Expr('null')], | 68 | 1 => ['is' => new \Zend_Db_Expr('null')], | |||
| 69 | ] | 69 | ] | |||
| 70 | ], | 70 | ], | |||
| 71 | 'left') | 71 | 'left') | |||
| 72 | ->addAttributeToSort( | 72 | ->addAttributeToSort( | |||
| 73 | 'news_from_date', | 73 | 'news_from_date', | |||
| 74 | 'desc') | 74 | 'desc') | |||
| 75 | ->addStoreFilter($this->getStoreId()) | 75 | ->addStoreFilter($this->getStoreId()) | |||
| 76 | ->setCurPage(1); | 76 | ->setCurPage(1); | |||
| 77 | } else { | 77 | } else { | |||
| 78 | $collection->addMinimalPrice() | 78 | $collection->addMinimalPrice() | |||
| 79 | ->addFinalPrice() | 79 | ->addFinalPrice() | |||
| 80 | ->addTaxPercents() | 80 | ->addTaxPercents() | |||
| 81 | ->addAttributeToSelect('name') | 81 | ->addAttributeToSelect('name') | |||
| 82 | ->addAttributeToSelect('image') | 82 | ->addAttributeToSelect('image') | |||
| 83 | ->addAttributeToSelect('small_image') | 83 | ->addAttributeToSelect('small_image') | |||
| 84 | ->addAttributeToSelect('thumbnail') | 84 | ->addAttributeToSelect('thumbnail') | |||
| 85 | ->addAttributeToFilter('special_price', ['neq' => '']) | 85 | ->addAttributeToFilter('special_price', ['neq' => '']) | |||
| 86 | ->addAttributeToSelect('special_from_date') | 86 | ->addAttributeToSelect('special_from_date') | |||
| 87 | ->addAttributeToSelect('special_to_date') | 87 | ->addAttributeToSelect('special_to_date') | |||
| 88 | ->addAttributeToFilter( | 88 | ->addAttributeToFilter( | |||
| 89 | 'special_from_date', | 89 | 'special_from_date', | |||
| 90 | ['date' => true, 'to' => $this->getEndOfDayDate()], | 90 | ['date' => true, 'to' => $this->getEndOfDayDate()], | |||
| 91 | 'left') | 91 | 'left') | |||
| 92 | ->addAttributeToFilter( | 92 | ->addAttributeToFilter( | |||
| 93 | 'special_to_date', | 93 | 'special_to_date', | |||
| 94 | [ | 94 | [ | |||
| 95 | 'or' => [ | 95 | 'or' => [ | |||
| 96 | 0 => ['date' => true, 'from' => $this->getStartOfDayDate()], | 96 | 0 => ['date' => true, 'from' => $this->getStartOfDayDate()], | |||
| 97 | 1 => ['is' => new \Zend_Db_Expr('null')], | 97 | 1 => ['is' => new \Zend_Db_Expr('null')], | |||
| 98 | ] | 98 | ] | |||
| 99 | ], | 99 | ], | |||
| 100 | 'left') | 100 | 'left') | |||
| 101 | ->addAttributeToSort( | 101 | ->addAttributeToSort( | |||
| 102 | 'news_from_date', | 102 | 'news_from_date', | |||
| 103 | 'desc') | 103 | 'desc') | |||
| 104 | ->addStoreFilter($this->getStoreId()) | 104 | ->addStoreFilter($this->getStoreId()) | |||
| 105 | ->setCurPage(1); | 105 | ->setCurPage(1); | |||
| 106 | } | 106 | } | |||
| 107 | 107 | |||||
| 108 | $collection->getSelect() | 108 | $collection->getSelect() | |||
| 109 | ->limit($count); | 109 | ->limit($count); | |||
| 110 | 110 | |||||
| 111 | return $collection; | 111 | return $collection; | |||
| 112 | } | 112 | } | |||
| 113 | 113 | |||||
| 114 | public function getLoadedProductCollection() { | 114 | public function getLoadedProductCollection() { | |||
| 115 | return $this->getProducts(); | 115 | return $this->getProducts(); | |||
| 116 | } | 116 | } | |||
| 117 | 117 | |||||
| 118 | public function getProductCount() { | 118 | public function getProductCount() { | |||
| 119 | $limit = $this->getData("product_count"); | 119 | $limit = $this->getData("product_count"); | |||
| 120 | if(!$limit) | 120 | if(!$limit) | |||
| 121 | $limit = 10; | 121 | $limit = 10; | |||
| 122 | return $limit; | 122 | return $limit; | |||
| 123 | } | 123 | } | |||
| 124 | 124 | |||||
| 125 | public function getStartOfDayDate() | 125 | public function getStartOfDayDate() | |||
| 126 | { | 126 | { | |||
| 127 | return $this->_localeDate->date()->setTime(0, 0, 0)->format('Y-m-d H:i:s'); | 127 | return $this->_localeDate->date()->setTime(0, 0, 0)->format('Y-m-d H:i:s'); | |||
| 128 | } | 128 | } | |||
| 129 | 129 | |||||
| 130 | public function getEndOfDayDate() | 130 | public function getEndOfDayDate() | |||
| 131 | { | 131 | { | |||
| 132 | return $this->_localeDate->date()->setTime(23, 59, 59)->format('Y-m-d H:i:s'); | 132 | return $this->_localeDate->date()->setTime(23, 59, 59)->format('Y-m-d H:i:s'); | |||
| 133 | } | 133 | } | |||
| 134 | 134 | |||||
| 135 | public function getStoreId() | 135 | public function getStoreId() | |||
| 136 | { | 136 | { | |||
| 137 | return $this->_storeManager->getStore()->getId(); | 137 | return $this->_storeManager->getStore()->getId(); | |||
| 138 | } | 138 | } | |||
| 139 | } | 139 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993–2019 Araxis Ltd (www.araxis.com). All rights reserved.