12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <?php
- /**
- * Mageplaza
- *
- * NOTICE OF LICENSE
- *
- * This source file is subject to the Mageplaza.com license that is
- * available through the world-wide-web at this URL:
- * https://www.mageplaza.com/LICENSE.txt
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade this extension to newer
- * version in the future.
- *
- * @category Mageplaza
- * @package Mageplaza_LayeredNavigation
- * @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
- * @license https://www.mageplaza.com/LICENSE.txt
- */
- namespace Mageplaza\LayeredNavigation\Helper;
- /**
- * Class Data
- * @package Mageplaza\LayeredNavigation\Helper
- */
- class Data extends \Mageplaza\AjaxLayer\Helper\Data
- {
- const FILTER_TYPE_SLIDER = 'slider';
- const FILTER_TYPE_LIST = 'list';
- /** @var \Mageplaza\LayeredNavigation\Model\Layer\Filter */
- protected $filterModel;
- /**
- * @param null $storeId
- *
- * @return mixed
- */
- public function isEnabled($storeId = null)
- {
- return $this->getConfigGeneral('enable', $storeId) && $this->isModuleOutputEnabled();
- }
- /**
- * @param $filters
- * @return mixed
- */
- public function getLayerConfiguration($filters)
- {
- $filterParams = $this->_getRequest()->getParams();
- foreach ($filterParams as $key => $param) {
- $filterParams[$key] = htmlspecialchars($param);
- }
- $config = new \Magento\Framework\DataObject([
- 'active' => array_keys($filterParams),
- 'params' => $filterParams,
- 'isCustomerLoggedIn' => $this->objectManager->create('Magento\Customer\Model\Session')->isLoggedIn(),
- 'isAjax' => $this->ajaxEnabled()
- ]);
- $this->getFilterModel()->getLayerConfiguration($filters, $config);
- return self::jsonEncode($config->getData());
- }
- /**
- * @return \Mageplaza\LayeredNavigation\Model\Layer\Filter
- */
- public function getFilterModel()
- {
- if (!$this->filterModel) {
- $this->filterModel = $this->objectManager->create('Mageplaza\LayeredNavigation\Model\Layer\Filter');
- }
- return $this->filterModel;
- }
- /**
- * @return \Magento\Framework\ObjectManagerInterface
- */
- public function getObjectManager()
- {
- return $this->objectManager;
- }
- }
|