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 | DailydealsList.php | 2023-07-01 15:03:38 +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 | DailydealsList.php | 2023-07-01 15:03:38 +0000 |
| Description | Between Files 1 and 2 | |
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 1 | 306 |
| 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 | 7 | |||||
| 8 | class DailydealsList extends \Magento\Catalog\Block\Product\ListProduct { | 8 | class DailydealsList extends \Magento\Catalog\Block\Product\ListProduct { | |||
| 9 | 9 | |||||
| 10 | protected $_collection; | 10 | protected $_collection; | |||
| 11 | 11 | |||||
| 12 | protected $categoryRepository; | 12 | protected $categoryRepository; | |||
| 13 | 13 | |||||
| 14 | protected $_resource; | 14 | protected $_resource; | |||
| 15 | 15 | |||||
| 16 | const DEFAULT_SHOW_PAGER = false; | 16 | const DEFAULT_SHOW_PAGER = false; | |||
| 17 | 17 | |||||
| 18 | const DEFAULT_PRODUCTS_PER_PAGE = 5; | 18 | const DEFAULT_PRODUCTS_PER_PAGE = 5; | |||
| 19 | 19 | |||||
| 20 | const PAGE_VAR_NAME = 'np'; | 20 | const PAGE_VAR_NAME = 'np'; | |||
| 21 | 21 | |||||
| 22 | protected $_pager; | 22 | protected $_pager; | |||
| 23 | 23 | |||||
| 24 | public function __construct( | 24 | public function __construct( | |||
| 25 | \Magento\Catalog\Block\Product\Context $context, | 25 | \Magento\Catalog\Block\Product\Context $context, | |||
| 26 | \Magento\Framework\Data\Helper\PostHelper $postDataHelper, | 26 | \Magento\Framework\Data\Helper\PostHelper $postDataHelper, | |||
| 27 | \Magento\Catalog\Model\Layer\Resolver $layerResolver, | 27 | \Magento\Catalog\Model\Layer\Resolver $layerResolver, | |||
| 28 | CategoryRepositoryInterface $categoryRepository, | 28 | CategoryRepositoryInterface $categoryRepository, | |||
| 29 | \Magento\Framework\Url\Helper\Data $urlHelper, | 29 | \Magento\Framework\Url\Helper\Data $urlHelper, | |||
| 30 | \Magento\Catalog\Model\ResourceModel\Product\Collection $collection, | 30 | \Magento\Catalog\Model\ResourceModel\Product\Collection $collection, | |||
| 31 | \Magento\Framework\App\ResourceConnection $resource, | 31 | \Magento\Framework\App\ResourceConnection $resource, | |||
| 32 | array $data = [], | 32 | array $data = [], | |||
| 33 | \Magento\Framework\Serialize\Serializer\Json $serializer = null | 33 | \Magento\Framework\Serialize\Serializer\Json $serializer = null | |||
| 34 | ) { | 34 | ) { | |||
| 35 | $this->categoryRepository = $categoryRepository; | 35 | $this->categoryRepository = $categoryRepository; | |||
| 36 | $this->_collection = $collection; | 36 | $this->_collection = $collection; | |||
| 37 | $this->_resource = $resource; | 37 | $this->_resource = $resource; | |||
| 38 | 38 | |||||
| 39 | parent::__construct($context, $postDataHelper, $layerResolver, $categoryRepository, $urlHelper, $data); | 39 | parent::__construct($context, $postDataHelper, $layerResolver, $categoryRepository, $urlHelper, $data); | |||
| 40 | 40 | |||||
| 41 | } | 41 | } | |||
| 42 | 42 | |||||
| 43 | protected function _getProductCollection() { | 43 | protected function _getProductCollection() { | |||
| 44 | return $this->getProducts(); | 44 | return $this->getProducts(); | |||
| 45 | } | 45 | } | |||
| 46 | 46 | |||||
| 47 | public function getCurrentPage() | 47 | public function getCurrentPage() | |||
| 48 | { | 48 | { | |||
| 49 | return abs((int)$this->getRequest()->getParam($this->getData('page_var_name'))); | 49 | return abs((int)$this->getRequest()->getParam($this->getData('page_var_name'))); | |||
| 50 | } | 50 | } | |||
| 51 | 51 | |||||
| 52 | public function getProducts() { | 52 | public function getProducts() { | |||
| 53 | $storeId = $this->_storeManager->getStore()->getId(); | 53 | $storeId = $this->_storeManager->getStore()->getId(); | |||
| 54 | $category_id = $this->getData("category_id"); | 54 | $category_id = $this->getData("category_id"); | |||
| 55 | $collection = clone $this->_collection; | 55 | $collection = clone $this->_collection; | |||
| 56 | $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); | 56 | $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); | |||
| 57 | if(!$category_id) { | 57 | if(!$category_id) { | |||
| 58 | $category_id = $this->_storeManager->getStore()->getRootCategoryId(); | 58 | $category_id = $this->_storeManager->getStore()->getRootCategoryId(); | |||
| 59 | } | 59 | } | |||
| 60 | $category = $this->categoryRepository->get($category_id); | 60 | $category = $this->categoryRepository->get($category_id); | |||
| 61 | 61 | |||||
| 62 | $collection->addMinimalPrice() | 62 | $collection->addMinimalPrice() | |||
| 63 | ->addFinalPrice() | 63 | ->addFinalPrice() | |||
| 64 | ->addTaxPercents() | 64 | ->addTaxPercents() | |||
| 65 | ->addAttributeToSelect('name') | 65 | ->addAttributeToSelect('name') | |||
| 66 | ->addAttributeToSelect('image') | 66 | ->addAttributeToSelect('image') | |||
| 67 | ->addAttributeToSelect('small_image') | 67 | ->addAttributeToSelect('small_image') | |||
| 68 | ->addAttributeToSelect('thumbnail') | 68 | ->addAttributeToSelect('thumbnail') | |||
| 69 | ->addUrlRewrite() | 69 | ->addUrlRewrite() | |||
| 70 | ->addStoreFilter($storeId); | 70 | ->addStoreFilter($storeId); | |||
| 71 | 71 | |||||
| 72 | if(isset($category) && $category) { | 72 | if(isset($category) && $category) { | |||
| 73 | $collection->addCategoryFilter($category); | 73 | $collection->addCategoryFilter($category); | |||
| 74 | } | 74 | } | |||
| 75 | 75 | |||||
| 76 | $collection->getSelect() | 76 | $collection->getSelect() | |||
| 77 | ->joinLeft(['dai' => $collection->getTable('sw_dailydeals_dailydeal')], 'dai.sw_product_sku = e.sku') | 77 | ->joinLeft(['dai' => $collection->getTable('sw_dailydeals_dailydeal')], 'dai.sw_product_sku = e.sku') | |||
| 78 | ->where('dai.sw_deal_enable=1') | 78 | ->where('dai.sw_deal_enable=1') | |||
| 79 | ->where( | 79 | ->where( | |||
| 80 | 'dai.sw_date_from <= "'.$this->getDayDate().'" or dai.sw_date_from IS NULL' | 80 | 'dai.sw_date_from <= "'.$this->getDayDate().'" or dai.sw_date_from IS NULL' | |||
| 81 | )->where( | 81 | )->where( | |||
| 82 | 'dai.sw_date_to >= "'.$this->getDayDate().'" or dai.sw_date_to IS NULL' | 82 | 'dai.sw_date_to >= "'.$this->getDayDate().'" or dai.sw_date_to IS NULL' | |||
| 83 | ); | 83 | ); | |||
| 84 | $collection | 84 | $collection | |||
| 85 | ->setPageSize($this->getPageSize()) | 85 | ->setPageSize($this->getPageSize()) | |||
| 86 | ->setCurPage($this->getCurrentPage()); | 86 | ->setCurPage($this->getCurrentPage()); | |||
| 87 | return $collection; | 87 | return $collection; | |||
| 88 | } | 88 | } | |||
| 89 | 89 | |||||
| 90 | public function getProductsCount() | 90 | public function getProductsCount() | |||
| 91 | { | 91 | { | |||
| 92 | if (!$this->hasData('product_count')) { | 92 | if (!$this->hasData('product_count')) { | |||
| 93 | return parent::getProductsCount(); | 93 | return parent::getProductsCount(); | |||
| 94 | } | 94 | } | |||
| 95 | return $this->getData('product_count'); | 95 | return $this->getData('product_count'); | |||
| 96 | } | 96 | } | |||
| 97 | 97 | |||||
| 98 | public function getProductsPerPage() | 98 | public function getProductsPerPage() | |||
| 99 | { | 99 | { | |||
| 100 | if (!$this->hasData('products_per_page')) { | 100 | if (!$this->hasData('products_per_page')) { | |||
| 101 | $this->setData('products_per_page', self::DEFAULT_PRODUCTS_PER_PAGE); | 101 | $this->setData('products_per_page', self::DEFAULT_PRODUCTS_PER_PAGE); | |||
| 102 | } | 102 | } | |||
| 103 | return $this->getData('products_per_page'); | 103 | return $this->getData('products_per_page'); | |||
| 104 | } | 104 | } | |||
| 105 | 105 | |||||
| 106 | public function showPager() | 106 | public function showPager() | |||
| 107 | { | 107 | { | |||
| 108 | if (!$this->hasData('show_pager')) { | 108 | if (!$this->hasData('show_pager')) { | |||
| 109 | $this->setData('show_pager', self::DEFAULT_SHOW_PAGER); | 109 | $this->setData('show_pager', self::DEFAULT_SHOW_PAGER); | |||
| 110 | } | 110 | } | |||
| 111 | return (bool)$this->getData('show_pager'); | 111 | return (bool)$this->getData('show_pager'); | |||
| 112 | } | 112 | } | |||
| 113 | 113 | |||||
| 114 | protected function getPageSize() | 114 | protected function getPageSize() | |||
| 115 | { | 115 | { | |||
| 116 | return $this->showPager() ? $this->getProductsPerPage() : $this->getProductsCount(); | 116 | return $this->showPager() ? $this->getProductsPerPage() : $this->getProductsCount(); | |||
| 117 | } | 117 | } | |||
| 118 | 118 | |||||
| 119 | public function getPagerHtml() | 119 | public function getPagerHtml() | |||
| 120 | { | 120 | { | |||
| 121 | if ($this->showPager()) { | 121 | if ($this->showPager()) { | |||
| 122 | if (!$this->_pager) { | 122 | if (!$this->_pager) { | |||
| 123 | $this->_pager = $this->getLayout()->createBlock( | 123 | $this->_pager = $this->getLayout()->createBlock( | |||
| 124 | \Magento\Catalog\Block\Product\Widget\Html\Pager::class, | 124 | \Magento\Catalog\Block\Product\Widget\Html\Pager::class, | |||
| 125 | 'widget.new.product.list.pager' | 125 | 'widget.new.product.list.pager' | |||
| 126 | ); | 126 | ); | |||
| 127 | 127 | |||||
| 128 | $this->_pager->setUseContainer(true) | 128 | $this->_pager->setUseContainer(true) | |||
| 129 | ->setShowAmounts(true) | 129 | ->setShowAmounts(true) | |||
| 130 | ->setShowPerPage(false) | 130 | ->setShowPerPage(false) | |||
| 131 | ->setPageVarName($this->getData('page_var_name')) | 131 | ->setPageVarName($this->getData('page_var_name')) | |||
| 132 | ->setLimit($this->getProductsPerPage()) | 132 | ->setLimit($this->getProductsPerPage()) | |||
| 133 | ->setTotalLimit($this->getProductsCount()) | 133 | ->setTotalLimit($this->getProductsCount()) | |||
| 134 | ->setCollection($this->_getProductCollection()); | 134 | ->setCollection($this->_getProductCollection()); | |||
| 135 | } | 135 | } | |||
| 136 | if ($this->_pager instanceof \Magento\Framework\View\Element\AbstractBlock) { | 136 | if ($this->_pager instanceof \Magento\Framework\View\Element\AbstractBlock) { | |||
| 137 | return $this->_pager->toHtml(); | 137 | return $this->_pager->toHtml(); | |||
| 138 | } | 138 | } | |||
| 139 | } | 139 | } | |||
| 140 | return ''; | 140 | return ''; | |||
| 141 | } | 141 | } | |||
| 142 | 142 | |||||
| 143 | protected function _beforeToHtml() | 143 | protected function _beforeToHtml() | |||
| 144 | { | 144 | { | |||
| 145 | $this->setProductCollection($this->_getProductCollection()); | 145 | $this->setProductCollection($this->_getProductCollection()); | |||
| 146 | return parent::_beforeToHtml(); | 146 | return parent::_beforeToHtml(); | |||
| 147 | } | 147 | } | |||
| 148 | 148 | |||||
| 149 | public function getDayDate() | 149 | public function getDayDate() | |||
| 150 | { | 150 | { | |||
| 151 | return $this->_localeDate->date()->format('Y-m-d H:i:s'); | 151 | return $this->_localeDate->date()->format('Y-m-d H:i:s'); | |||
| 152 | } | 152 | } | |||
| 153 | } | 153 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993–2019 Araxis Ltd (www.araxis.com). All rights reserved.