Example #1
0
 /**
  * @param \Magento\Catalog\Model\Layer\AvailabilityFlagInterface $subject
  * @param callable $proceed
  * @param \Magento\Catalog\Model\Layer $layer
  * @param array $filters
  * @return bool
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function aroundIsEnabled(\Magento\Catalog\Model\Layer\AvailabilityFlagInterface $subject, \Closure $proceed, $layer, $filters)
 {
     $_isLNAllowedByEngine = $this->engineProvider->get()->isLayeredNavigationAllowed();
     if (!$_isLNAllowedByEngine) {
         return false;
     }
     $availableResCount = (int) $this->scopeConfig->getValue(self::XML_PATH_DISPLAY_LAYER_COUNT, \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
     if (!$availableResCount || $availableResCount > $layer->getProductCollection()->getSize()) {
         return $proceed($layer, $filters);
     }
     return false;
 }
Example #2
0
 /**
  * Save Multiply Product indexes
  *
  * @param int $storeId
  * @param array $productIndexes
  * @return $this
  */
 protected function saveProductIndexes($storeId, $productIndexes)
 {
     if ($this->engineProvider->get()) {
         $this->engineProvider->get()->saveEntityIndexes($storeId, $productIndexes);
     }
     return $this;
 }
Example #3
0
 /**
  * Construct
  *
  * @param Context $context
  * @param Registry $registry
  * @param CollectionFactory $attributeCollectionFactory
  * @param Visibility $catalogProductVisibility
  * @param Config $catalogConfig
  * @param EngineProvider $engineProvider
  * @param CurrencyFactory $currencyFactory
  * @param ProductFactory $productFactory
  * @param StoreManagerInterface $storeManager
  * @param array $data
  */
 public function __construct(Context $context, Registry $registry, CollectionFactory $attributeCollectionFactory, Visibility $catalogProductVisibility, Config $catalogConfig, EngineProvider $engineProvider, CurrencyFactory $currencyFactory, ProductFactory $productFactory, StoreManagerInterface $storeManager, array $data = array())
 {
     $this->_attributeCollectionFactory = $attributeCollectionFactory;
     $this->_catalogProductVisibility = $catalogProductVisibility;
     $this->_catalogConfig = $catalogConfig;
     $this->_engine = $engineProvider->get();
     $this->_currencyFactory = $currencyFactory;
     $this->_productFactory = $productFactory;
     $this->_storeManager = $storeManager;
     parent::__construct($context, $registry, $this->_engine->getResource(), $this->_engine->getResourceCollection(), $data);
 }
Example #4
0
 /**
  * @param \Magento\Framework\App\Resource $resource
  * @param \Magento\Catalog\Model\Product\Type $catalogProductType
  * @param \Magento\Eav\Model\Config $eavConfig
  * @param \Magento\Framework\Search\Request\Config $searchRequestConfig
  * @param \Magento\Catalog\Model\Product\Attribute\Source\Status $catalogProductStatus
  * @param \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $productAttributeCollectionFactory
  * @param \Magento\CatalogSearch\Model\Resource\EngineProvider $engineProvider
  * @param \Magento\CatalogSearch\Model\Indexer\IndexerHandlerFactory $indexHandlerFactory
  * @param \Magento\Framework\Event\ManagerInterface $eventManager
  * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
  * @param \Magento\Store\Model\StoreManagerInterface $storeManager
  * @param \Magento\Framework\Stdlib\DateTime $dateTime
  * @param \Magento\Framework\Locale\ResolverInterface $localeResolver
  * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
  * @param \Magento\CatalogSearch\Model\Resource\Fulltext $fulltextResource
  * @param \Magento\Framework\Search\Request\DimensionFactory $dimensionFactory
  * @param \Magento\Indexer\Model\ConfigInterface $indexerConfig
  * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  */
 public function __construct(\Magento\Framework\App\Resource $resource, \Magento\Catalog\Model\Product\Type $catalogProductType, \Magento\Eav\Model\Config $eavConfig, \Magento\Framework\Search\Request\Config $searchRequestConfig, \Magento\Catalog\Model\Product\Attribute\Source\Status $catalogProductStatus, \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $productAttributeCollectionFactory, \Magento\CatalogSearch\Model\Resource\EngineProvider $engineProvider, \Magento\CatalogSearch\Model\Indexer\IndexerHandlerFactory $indexHandlerFactory, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\Stdlib\DateTime $dateTime, \Magento\Framework\Locale\ResolverInterface $localeResolver, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\CatalogSearch\Model\Resource\Fulltext $fulltextResource, \Magento\Framework\Search\Request\DimensionFactory $dimensionFactory, \Magento\Indexer\Model\ConfigInterface $indexerConfig)
 {
     $this->resource = $resource;
     $this->catalogProductType = $catalogProductType;
     $this->eavConfig = $eavConfig;
     $this->searchRequestConfig = $searchRequestConfig;
     $this->catalogProductStatus = $catalogProductStatus;
     $this->productAttributeCollectionFactory = $productAttributeCollectionFactory;
     $this->eventManager = $eventManager;
     $this->scopeConfig = $scopeConfig;
     $this->storeManager = $storeManager;
     $this->engine = $engineProvider->get();
     $configData = $indexerConfig->getIndexer(Fulltext::INDEXER_ID);
     $this->indexHandler = $indexHandlerFactory->create(['data' => $configData]);
     $this->dateTime = $dateTime;
     $this->localeResolver = $localeResolver;
     $this->localeDate = $localeDate;
     $this->fulltextResource = $fulltextResource;
     $this->dimensionFactory = $dimensionFactory;
 }