120. Araxis Merge File Comparison Report

Produced by Araxis Merge on 2023-07-12 04:42:39 +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.

120.1 Files compared

#LocationFileLast Modified
12023-07-12 04:42:39 +0000
2Porto v4.0.6/Theme Files/Porto Theme/app/code/Smartwave/Filterproducts/Block/HomeDailydealsList.php2023-07-01 15:03:38 +0000

120.2 Comparison summary

DescriptionBetween
Files 1 and 2
Text BlocksLines
Unchanged00
Changed00
Inserted1153
Removed00

120.3 Comparison options

WhitespaceConsecutive whitespace is treated as a single space
Character caseDifferences in character case are significant
Line endingsDifferences in line endings (CR and LF characters) are ignored
CR/LF charactersNot shown in the comparison detail
Active line-pairing rules

120.4 Active regular expressions

No regular expressions were active.

120.5 Comparison detail

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