Data.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /**
  3. * Mageplaza
  4. *
  5. * NOTICE OF LICENSE
  6. *
  7. * This source file is subject to the Mageplaza.com license that is
  8. * available through the world-wide-web at this URL:
  9. * https://www.mageplaza.com/LICENSE.txt
  10. *
  11. * DISCLAIMER
  12. *
  13. * Do not edit or add to this file if you wish to upgrade this extension to newer
  14. * version in the future.
  15. *
  16. * @category Mageplaza
  17. * @package Mageplaza_AjaxLayer
  18. * @copyright Copyright (c) Mageplaza (http://www.mageplaza.com/)
  19. * @license https://www.mageplaza.com/LICENSE.txt
  20. */
  21. namespace Mageplaza\AjaxLayer\Helper;
  22. use Mageplaza\Core\Helper\AbstractData;
  23. /**
  24. * Class Data
  25. * @package Mageplaza\LayeredNavigation\Helper
  26. */
  27. class Data extends AbstractData
  28. {
  29. const CONFIG_MODULE_PATH = 'layered_navigation';
  30. const FILTER_TYPE_LIST = 'list';
  31. /** @var \Mageplaza\LayeredNavigation\Model\Layer\Filter */
  32. protected $filterModel;
  33. /**
  34. * @param null $storeId
  35. *
  36. * @return mixed
  37. */
  38. public function ajaxEnabled($storeId = null)
  39. {
  40. return $this->getConfigGeneral('ajax_enable', $storeId) && $this->isModuleOutputEnabled();
  41. }
  42. /**
  43. * @param $filters
  44. * @return mixed
  45. */
  46. public function getLayerConfiguration($filters)
  47. {
  48. $filterParams = $this->_getRequest()->getParams();
  49. $config = new \Magento\Framework\DataObject([
  50. 'active' => array_keys($filterParams),
  51. 'params' => $filterParams,
  52. 'isCustomerLoggedIn' => $this->objectManager->create('Magento\Customer\Model\Session')->isLoggedIn()
  53. ]);
  54. return self::jsonEncode($config->getData());
  55. }
  56. }