ltsecurityinc安防产品在线商城代码
This commit is contained in:
+14
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Olegnax
|
||||
* @package Olegnax_LayeredNavigation
|
||||
* @copyright Copyright (c) 2019 Olegnax (http://olegnax.com/). All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
namespace Olegnax\LayeredNavigation\Block\Adminhtml\System\Config\Form;
|
||||
|
||||
class Info extends \Olegnax\Core\Block\Adminhtml\System\Config\Form\Info
|
||||
{
|
||||
}
|
||||
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Olegnax
|
||||
* @package Olegnax_LayeredNavigation
|
||||
* @copyright Copyright (c) 2019 Olegnax (http://olegnax.com/). All rights reserved.
|
||||
* @license Proprietary License https://olegnax.com/license/
|
||||
*/
|
||||
|
||||
namespace Olegnax\LayeredNavigation\Block\LayeredNavigation;
|
||||
|
||||
use Magento\Catalog\Model\Layer\Filter\Item as FilterItem;
|
||||
use Magento\Catalog\Model\ResourceModel\Layer\Filter\AttributeFactory;
|
||||
use Magento\Eav\Model\Entity\Attribute;
|
||||
use Magento\Eav\Model\Entity\Attribute\Option;
|
||||
use Magento\Framework\UrlInterface;
|
||||
use Magento\Framework\View\Element\Template\Context;
|
||||
use Magento\Swatches\Helper\Data;
|
||||
use Magento\Swatches\Helper\Media;
|
||||
use Olegnax\LayeredNavigation\Helper\Helper;
|
||||
use Olegnax\LayeredNavigation\Model\Layer\Filter;
|
||||
use Magento\Theme\Block\Html\Pager;
|
||||
|
||||
class RenderLayered extends \Magento\Swatches\Block\LayeredNavigation\RenderLayered
|
||||
{
|
||||
|
||||
protected $_url;
|
||||
protected $_helper;
|
||||
protected $_filter;
|
||||
protected $_template = 'Olegnax_LayeredNavigation::product/layered/renderer.phtml';
|
||||
|
||||
/**
|
||||
* RenderLayered constructor.
|
||||
* @param Context $context
|
||||
* @param Attribute $eavAttribute
|
||||
* @param AttributeFactory $layerAttribute
|
||||
* @param Data $swatchHelper
|
||||
* @param Media $mediaHelper
|
||||
* @param UrlInterface $url
|
||||
* @param Helper $helper
|
||||
* @param Filter $filter
|
||||
* @param array $data
|
||||
* @param Pager|null $htmlPagerBlock
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Attribute $eavAttribute,
|
||||
AttributeFactory $layerAttribute,
|
||||
Data $swatchHelper,
|
||||
Media $mediaHelper,
|
||||
UrlInterface $url,
|
||||
Helper $helper,
|
||||
Filter $filter,
|
||||
array $data = [],
|
||||
?Pager $htmlPagerBlock = null
|
||||
) {
|
||||
$this->_url = $url;
|
||||
$this->_helper = $helper;
|
||||
$this->_filter = $filter;
|
||||
parent::__construct($context, $eavAttribute, $layerAttribute, $swatchHelper, $mediaHelper, $data, $htmlPagerBlock);
|
||||
}
|
||||
|
||||
protected function getOptionViewData(FilterItem $item, Option $swatchOption)
|
||||
{
|
||||
$result = parent::getOptionViewData($item, $swatchOption);
|
||||
|
||||
if (!$this->_helper->isEnabled() || $this->isOptionDisabled($item)) {
|
||||
return $result;
|
||||
}
|
||||
$filter = $item->getFilter();
|
||||
$itemValue = $item->getValue();
|
||||
$value = [is_array($itemValue) ? implode('-', $itemValue) : $itemValue];
|
||||
if ($this->_filter->isMultiselect($filter)) {
|
||||
$value = array_merge($this->_filter->getFilterValue($filter), $value);
|
||||
$value = array_unique($value);
|
||||
}
|
||||
|
||||
$query = [
|
||||
$filter->getRequestVar() => implode(',', $value),
|
||||
];
|
||||
|
||||
$result['link'] = $this->_url->getUrl(
|
||||
'*/*/*',
|
||||
[
|
||||
'_current' => true,
|
||||
'_use_rewrite' => true,
|
||||
'_query' => $query
|
||||
]
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
+134
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Olegnax
|
||||
* @package Olegnax_LayeredNavigation
|
||||
* @copyright Copyright (c) 2019 Olegnax (http://olegnax.com/). All rights reserved.
|
||||
* @license Proprietary License https://olegnax.com/license/
|
||||
*/
|
||||
|
||||
namespace Olegnax\LayeredNavigation\Block;
|
||||
|
||||
use Magento\Catalog\Helper\Product\ProductList;
|
||||
use Magento\Catalog\Model\Layer\AvailabilityFlagInterface;
|
||||
use Magento\Catalog\Model\Layer\FilterList;
|
||||
use Magento\Catalog\Model\Layer\Resolver;
|
||||
use Magento\Catalog\Model\Product\ProductList\Toolbar;
|
||||
use Magento\Framework\View\Element\Template\Context;
|
||||
use Olegnax\LayeredNavigation\Helper\Helper;
|
||||
|
||||
class Navigation extends \Magento\LayeredNavigation\Block\Navigation
|
||||
{
|
||||
|
||||
protected $_catalogLayer;
|
||||
protected $filterList;
|
||||
protected $visibilityFlag;
|
||||
protected $_productListHelper;
|
||||
protected $_orderField = null;
|
||||
protected $_direction = ProductList::DEFAULT_SORT_DIRECTION;
|
||||
/**
|
||||
* @var Helper
|
||||
*/
|
||||
protected $_helper;
|
||||
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Resolver $layerResolver,
|
||||
FilterList $filterList,
|
||||
AvailabilityFlagInterface $visibilityFlag,
|
||||
ProductList $productListHelper,
|
||||
Helper $helper,
|
||||
array $data = []
|
||||
) {
|
||||
$this->_catalogLayer = $layerResolver->get();
|
||||
$this->filterList = $filterList;
|
||||
$this->visibilityFlag = $visibilityFlag;
|
||||
$this->_productListHelper = $productListHelper;
|
||||
$this->_helper = $helper;
|
||||
parent::__construct($context, $layerResolver, $filterList, $visibilityFlag, $data);
|
||||
}
|
||||
|
||||
public function AjaxEnabled()
|
||||
{
|
||||
return $this->_helper->AjaxEnabled();
|
||||
}
|
||||
|
||||
public function isCategoryFilter($filter)
|
||||
{
|
||||
return ($filter->getRequestVar() == 'cat') ? true : false;
|
||||
}
|
||||
|
||||
public function getFilterButtonHtml()
|
||||
{
|
||||
return $this->_helper->getFilterButtonStyle();
|
||||
}
|
||||
|
||||
public function getActiveFilters()
|
||||
{
|
||||
$filters = $this->getFilters();
|
||||
$activeFilters = [];
|
||||
$ctr = 0;
|
||||
foreach ($filters as $k => $filter) {
|
||||
if ($filter->getRequestVar() == 'cat') {
|
||||
if ($filter->getItemsCount()) {
|
||||
$ctr++;
|
||||
}
|
||||
continue;
|
||||
} else {
|
||||
if ($filter->getItemsCount()) {
|
||||
$attributeId = $filter->getAttributeModel()->getAttributeId();
|
||||
if ($attributeId) {
|
||||
//$activeFilters[] = $ctr;
|
||||
}
|
||||
$ctr++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$activeFiltersStr = implode(' ', $activeFilters);
|
||||
|
||||
return $activeFiltersStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve widget options in json format
|
||||
*
|
||||
* @param array $customOptions Optional parameter for passing custom selectors from template
|
||||
* @return string
|
||||
*/
|
||||
public function getWidgetOptionsJson(array $customOptions = [])
|
||||
{
|
||||
$defaultMode = $this->_productListHelper->getDefaultViewMode($this->getModes());
|
||||
$options = [
|
||||
'mode' => Toolbar::MODE_PARAM_NAME,
|
||||
'direction' => Toolbar::DIRECTION_PARAM_NAME,
|
||||
'order' => Toolbar::ORDER_PARAM_NAME,
|
||||
'limit' => Toolbar::LIMIT_PARAM_NAME,
|
||||
'modeDefault' => $defaultMode,
|
||||
'directionDefault' => $this->_direction ?: ProductList::DEFAULT_SORT_DIRECTION,
|
||||
'orderDefault' => $this->getOrderField(),
|
||||
'limitDefault' => $this->_productListHelper->getDefaultLimitPerPageValue($defaultMode),
|
||||
'url' => $this->getPagerUrl(),
|
||||
];
|
||||
$options = array_replace_recursive($options, $customOptions);
|
||||
return json_encode(['productListToolbarForm' => $options]);
|
||||
}
|
||||
|
||||
protected function getOrderField()
|
||||
{
|
||||
if ($this->_orderField === null) {
|
||||
$this->_orderField = $this->_productListHelper->getDefaultSortField();
|
||||
}
|
||||
return $this->_orderField;
|
||||
}
|
||||
|
||||
public function getPagerUrl($params = [])
|
||||
{
|
||||
$urlParams = [];
|
||||
$urlParams['_current'] = true;
|
||||
$urlParams['_escape'] = false;
|
||||
$urlParams['_use_rewrite'] = true;
|
||||
$urlParams['_query'] = $params;
|
||||
return $this->getUrl('*/*/*', $urlParams);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Olegnax
|
||||
* @package Olegnax_LayeredNavigation
|
||||
* @copyright Copyright (c) 2019 Olegnax (http://olegnax.com/). All rights reserved.
|
||||
* @license Proprietary License https://olegnax.com/license/
|
||||
*/
|
||||
|
||||
namespace Olegnax\LayeredNavigation\Block\Navigation;
|
||||
|
||||
use Magento\Catalog\Model\Layer\Resolver;
|
||||
use Magento\Framework\View\Element\Template\Context;
|
||||
|
||||
class State extends \Magento\LayeredNavigation\Block\Navigation\State
|
||||
{
|
||||
|
||||
protected $_template = 'Olegnax_LayeredNavigation::layer/state.phtml';
|
||||
protected $_catalogLayer;
|
||||
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Resolver $layerResolver,
|
||||
array $data = []
|
||||
) {
|
||||
$this->_catalogLayer = $layerResolver->get();
|
||||
parent::__construct($context, $layerResolver, $data);
|
||||
}
|
||||
|
||||
}
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* A Magento 2 module named Olegnax/LayeredNavigation
|
||||
* Copyright (C) 2019
|
||||
*
|
||||
* This file is part of Olegnax/LayeredNavigation.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Olegnax.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.olegnax.com/license
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Block
|
||||
* @package Olegnax_LayeredNavigation
|
||||
* @copyright Copyright (c) 2010-2019 Olegnax (http://www.olegnax.com/)
|
||||
* @license https://www.olegnax.com/license
|
||||
*/
|
||||
|
||||
namespace Olegnax\LayeredNavigation\Block;
|
||||
|
||||
use Magento\Catalog\Model\Layer;
|
||||
use Magento\Catalog\Model\Layer\Resolver;
|
||||
use Magento\Framework\App\ObjectManager;
|
||||
use Magento\Framework\Serialize\Serializer\Json;
|
||||
use Magento\Framework\View\Element\Template\Context;
|
||||
use Olegnax\Core\Block\Template as coreTemplate;
|
||||
use Olegnax\LayeredNavigation\Helper\Helper;
|
||||
|
||||
class Template extends coreTemplate
|
||||
{
|
||||
protected $helper;
|
||||
/**
|
||||
* @var Json|mixed|null
|
||||
*/
|
||||
protected $json;
|
||||
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Helper $helper,
|
||||
Json $json = null,
|
||||
array $data = []
|
||||
) {
|
||||
$this->helper = $helper;
|
||||
$this->json = $json ?: ObjectManager::getInstance()->get(Json::class);
|
||||
parent::__construct($context, $data);
|
||||
}
|
||||
|
||||
public function getNavConfig()
|
||||
{
|
||||
$config = [
|
||||
'clearUrl' => $this->getClearUrl(),
|
||||
'scrollToTop' => 1,
|
||||
'loaderFilter' => (bool)$this->getModuleLoadersConfig('loader_type_filters'),
|
||||
'loaderContent' => (bool)$this->getModuleLoadersConfig('loader_type_content'),
|
||||
'loaderPage' => (bool)$this->getModuleLoadersConfig('loader_type_page'),
|
||||
'abortPrev' => (bool)$this->helper->getModuleConfig('general/abort_prev_request'),
|
||||
];
|
||||
if ($config['loaderContent']) {
|
||||
$config['loaderContentSelector'] = $this->getSelectorProducts();
|
||||
}
|
||||
|
||||
return $this->json->serialize($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve Clear Filters URL
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getClearUrl()
|
||||
{
|
||||
$filterState = [];
|
||||
foreach ($this->getActiveFilters() as $item) {
|
||||
$filterState[$item->getFilter()->getRequestVar()] = $item->getFilter()->getCleanValue();
|
||||
}
|
||||
$params['_current'] = true;
|
||||
$params['_use_rewrite'] = true;
|
||||
$params['_query'] = $filterState;
|
||||
$params['_escape'] = true;
|
||||
return $this->_urlBuilder->getUrl('*/*/*', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve active filters
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getActiveFilters()
|
||||
{
|
||||
$filters = $this->getLayer()->getState()->getFilters();
|
||||
if (!is_array($filters)) {
|
||||
$filters = [];
|
||||
}
|
||||
return $filters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve Layer object
|
||||
*
|
||||
* @return Layer
|
||||
*/
|
||||
public function getLayer()
|
||||
{
|
||||
if (!$this->hasData('layer')) {
|
||||
$_catalogLayer = $this->_loadObject(Resolver::class)->get();
|
||||
$this->setLayer($_catalogLayer);
|
||||
}
|
||||
return $this->_getData('layer');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param null $storeCode
|
||||
* @return mixed
|
||||
*/
|
||||
public function getModuleLoadersConfig($path = '', $storeCode = null)
|
||||
{
|
||||
return $this->helper->getModuleConfig('loaders/' . $path, $storeCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSelectorProducts()
|
||||
{
|
||||
$products_container = $this->getModuleLoadersConfig('loader_content_selector') ?: '.column.main .products.products-grid, .column.main .products.products-list, .column.main .products-grid.grid';
|
||||
return $products_container;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user