ltsecurityinc安防产品在线商城代码
This commit is contained in:
+96
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Amasty Team
|
||||
* @copyright Copyright (c) Amasty (https://www.amasty.com)
|
||||
* @package Improved Sorting for Magento 2
|
||||
*/
|
||||
|
||||
namespace Amasty\Sorting\Block\Adminhtml;
|
||||
|
||||
use Magento\Backend\Block\Template\Context;
|
||||
use Magento\Config\Block\System\Config\Form\Field;
|
||||
use Magento\Framework\Data\Form\Element\AbstractElement;
|
||||
use Amasty\Sorting\Helper\Data as SortingHelper;
|
||||
use Magento\Catalog\Model\Config;
|
||||
|
||||
class Position extends Field
|
||||
{
|
||||
/**
|
||||
* @var SortingHelper
|
||||
*/
|
||||
private $helper;
|
||||
|
||||
/**
|
||||
* @var Config
|
||||
*/
|
||||
private $config;
|
||||
|
||||
public function __construct(
|
||||
SortingHelper $helper,
|
||||
Config $config,
|
||||
Context $context
|
||||
) {
|
||||
parent::__construct($context);
|
||||
$this->helper = $helper;
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
protected function _construct()
|
||||
{
|
||||
$this->setTemplate('Amasty_Sorting::/position.phtml');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AbstractElement $element
|
||||
* @return string
|
||||
*/
|
||||
public function render(AbstractElement $element)
|
||||
{
|
||||
$this->setElement($element);
|
||||
|
||||
return $this->_toHtml();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getPositions()
|
||||
{
|
||||
$positions = (array) $this->helper->getSortOrder();
|
||||
if ($positions === []) {
|
||||
$positions = $this->getOptionalArray();
|
||||
} else {
|
||||
$availableOptions = $this->getOptionalArray();
|
||||
// delete disabled options
|
||||
$positions = array_intersect($availableOptions, $positions);
|
||||
$newOptions = array_diff($availableOptions, $positions);
|
||||
$positions = array_merge($positions, $newOptions);
|
||||
}
|
||||
|
||||
return $positions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $index
|
||||
* @return string
|
||||
*/
|
||||
public function getNamePrefix($index)
|
||||
{
|
||||
return $this->getElement()->getName() . '[' . $index . ']';
|
||||
}
|
||||
|
||||
private function getOptionalArray()
|
||||
{
|
||||
$positions = [];
|
||||
$methods = $this->config->getAttributeUsedForSortByArray();
|
||||
foreach ($methods as $key => $methodObject) {
|
||||
if (is_object($methodObject)) {
|
||||
$positions[$key] = $methodObject->getText();
|
||||
} else {
|
||||
$positions[$key] = $methodObject;
|
||||
}
|
||||
}
|
||||
|
||||
return $positions;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Amasty Team
|
||||
* @copyright Copyright (c) Amasty (https://www.amasty.com)
|
||||
* @package Improved Sorting for Magento 2
|
||||
*/
|
||||
|
||||
namespace Amasty\Sorting\Block\Adminhtml\System\Config;
|
||||
|
||||
class DisableSorting extends \Magento\Config\Block\System\Config\Form\Field
|
||||
{
|
||||
public const REPLACE_TARGET = 'category_edit_url';
|
||||
|
||||
/**
|
||||
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
|
||||
*
|
||||
* @return mixed|string
|
||||
*/
|
||||
protected function _renderValue(\Magento\Framework\Data\Form\Element\AbstractElement $element)
|
||||
{
|
||||
$value = parent::_renderValue($element);
|
||||
$value = str_replace(self::REPLACE_TARGET, $this->getUrl('catalog/category/index'), $value);
|
||||
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Amasty Team
|
||||
* @copyright Copyright (c) Amasty (https://www.amasty.com)
|
||||
* @package Improved Sorting for Magento 2
|
||||
*/
|
||||
|
||||
namespace Amasty\Sorting\Block\Adminhtml\System\Config;
|
||||
|
||||
use Magento\Framework\Data\Form\Element\AbstractElement;
|
||||
|
||||
class Information extends \Magento\Config\Block\System\Config\Form\Fieldset
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $userGuide = 'https://amasty.com/docs/doku.php?id=magento_2:improved-sorting';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $enemyExtensions = [];
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $content;
|
||||
|
||||
/**
|
||||
* @var \Magento\Framework\Module\Manager
|
||||
*/
|
||||
private $moduleManager;
|
||||
|
||||
public function __construct(
|
||||
\Magento\Backend\Block\Context $context,
|
||||
\Magento\Backend\Model\Auth\Session $authSession,
|
||||
\Magento\Framework\View\Helper\Js $jsHelper,
|
||||
\Magento\Framework\Module\Manager $moduleManager,
|
||||
array $data = []
|
||||
) {
|
||||
parent::__construct($context, $authSession, $jsHelper, $data);
|
||||
$this->moduleManager = $moduleManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render fieldset html
|
||||
*
|
||||
* @param AbstractElement $element
|
||||
* @return string
|
||||
*/
|
||||
public function render(AbstractElement $element)
|
||||
{
|
||||
$html = $this->_getHeaderHtml($element);
|
||||
|
||||
$this->setContent(__('Please update Amasty Base module. Re-upload it and replace all the files.'));
|
||||
|
||||
$this->_eventManager->dispatch(
|
||||
'amasty_base_add_information_content',
|
||||
['block' => $this]
|
||||
);
|
||||
|
||||
$html .= $this->getContent();
|
||||
$html .= $this->_getFooterHtml($element);
|
||||
|
||||
$html = str_replace(
|
||||
'amasty_information]" type="hidden" value="0"',
|
||||
'amasty_information]" type="hidden" value="1"',
|
||||
$html
|
||||
);
|
||||
$html = preg_replace('(onclick=\"Fieldset.toggleCollapse.*?\")', '', $html);
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|string
|
||||
*/
|
||||
public function getAdditionalModuleContent()
|
||||
{
|
||||
if ($this->moduleManager->isEnabled('Magento_GraphQl')
|
||||
&& !$this->moduleManager->isEnabled('Amasty_SortingGraphQl')
|
||||
) {
|
||||
$result[] = [
|
||||
'type' => 'message-notice',
|
||||
'text' => __('Enable improved-sorting-graphql module to '
|
||||
. 'activate GraphQl and Sorting. '
|
||||
. 'Please, run the following command in the SSH: '
|
||||
. 'composer require amasty/improved-sorting-graphql')
|
||||
];
|
||||
}
|
||||
|
||||
if ($this->moduleManager->isEnabled('Yotpo_Yotpo')
|
||||
&& !$this->moduleManager->isEnabled('Amasty_Yotpo')
|
||||
) {
|
||||
$result[] = [
|
||||
'type' => 'message-notice',
|
||||
'text' => __('Enable amasty/yotpo module to '
|
||||
. 'activate Yotpo and Sorting. '
|
||||
. 'Please, run the following command in the SSH: '
|
||||
. 'composer require amasty/yotpo')
|
||||
];
|
||||
}
|
||||
|
||||
return $result ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUserGuide()
|
||||
{
|
||||
return $this->userGuide;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $userGuide
|
||||
*/
|
||||
public function setUserGuide($userGuide)
|
||||
{
|
||||
$this->userGuide = $userGuide;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getEnemyExtensions()
|
||||
{
|
||||
return $this->enemyExtensions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $enemyExtensions
|
||||
*/
|
||||
public function setEnemyExtensions($enemyExtensions)
|
||||
{
|
||||
$this->enemyExtensions = $enemyExtensions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getContent()
|
||||
{
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $content
|
||||
*/
|
||||
public function setContent($content)
|
||||
{
|
||||
$this->content = $content;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @author Amasty Team
|
||||
* @copyright Copyright (c) Amasty (https://www.amasty.com)
|
||||
* @package Improved Sorting for Magento 2
|
||||
*/
|
||||
|
||||
namespace Amasty\Sorting\Block\Adminhtml\System\Config;
|
||||
|
||||
use Magento\Framework\Data\Form\Element\AbstractElement;
|
||||
|
||||
class SortingNotice extends \Magento\Config\Block\System\Config\Form\Fieldset
|
||||
{
|
||||
/**
|
||||
* @var \Amasty\Sorting\Model\Di\Wrapper
|
||||
*/
|
||||
private $ruleCollection;
|
||||
|
||||
public function __construct(
|
||||
\Magento\Backend\Block\Context $context,
|
||||
\Magento\Backend\Model\Auth\Session $authSession,
|
||||
\Magento\Framework\View\Helper\Js $jsHelper,
|
||||
\Amasty\Sorting\Model\Di\Wrapper $ruleCollection,
|
||||
array $data = []
|
||||
) {
|
||||
parent::__construct($context, $authSession, $jsHelper, $data);
|
||||
$this->ruleCollection = $ruleCollection;
|
||||
}
|
||||
|
||||
public function render(AbstractElement $element)
|
||||
{
|
||||
$this->setElement($element);
|
||||
$header = $this->_getHeaderHtml($element);
|
||||
|
||||
$elements = $this->_getChildrenElementsHtml($element);
|
||||
|
||||
$footer = $this->_getFooterHtml($element);
|
||||
|
||||
$notice = $this->generateNoticeMessageHtml();
|
||||
|
||||
return $header . $notice . $elements . $footer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function generateNoticeMessageHtml(): string
|
||||
{
|
||||
$content = '';
|
||||
|
||||
if ($this->ruleCollection->getSize()) {
|
||||
$content = '<div class="amasty-info-block">'
|
||||
. '<div class="amasty-additional-content"><span class="message message-notice">'
|
||||
. __(
|
||||
'Please kindly note: if products on a search results page match the conditions of Amasty Elastic '
|
||||
. 'Search Relevance Rules, the settings listed below will be ignored and products '
|
||||
. 'will get sorted by relevance'
|
||||
)
|
||||
. '</div></div></div>';
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user