ltsecurityinc安防产品在线商城代码

This commit is contained in:
2026-09-14 17:47:10 +08:00
parent 57d8444c15
commit 6a3c9c5bd8
14539 changed files with 1775310 additions and 0 deletions
+96
View File
@@ -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;
}
}
+95
View File
@@ -0,0 +1,95 @@
<?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;
use Amasty\Sorting\Helper\Data;
use Magento\Framework\View\Element\Template;
use Magento\Framework\View\Element\Template\Context;
use Amasty\Base\Model\Serializer as JsonSerializer;
class Direction extends Template
{
public const PERMANENT_DIRECTION_ATTRIBUTES = [
'price_asc',
'price_desc'
];
/**
* @var string
*/
protected $_template = 'Amasty_Sorting::direction.phtml';
/**
* @var Data
*/
private $helper;
/**
* @var JsonSerializer
*/
private $jsonSerializer;
public function __construct(
Data $helper,
JsonSerializer $jsonSerializer,
Context $context,
array $data = []
) {
parent::__construct($context, $data);
$this->helper = $helper;
$this->jsonSerializer = $jsonSerializer;
}
/**
* @return string
*/
protected function _toHtml()
{
$result = '';
if ($this->isDirectionCanBeHide()) {
$result = parent::_toHtml();
}
return $result;
}
/**
* @return bool
*/
private function isDirectionCanBeHide(): bool
{
$result = false;
foreach ($this->getPermanentDirectionAttributes() as $attribute) {
if ($result = !$this->helper->isMethodDisabled($attribute)) {
break;
}
}
return $result;
}
/**
* @return array
*/
public function getPermanentDirectionAttributes(): array
{
return static::PERMANENT_DIRECTION_ATTRIBUTES;
}
/**
* @return string
*/
public function getPermanentDirectionAttributesJson(): string
{
return $this->jsonSerializer->serialize($this->getPermanentDirectionAttributes());
}
}
+118
View File
@@ -0,0 +1,118 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Improved Sorting for Magento 2
*/
namespace Amasty\Sorting\Block\Widget;
use Amasty\Sorting\Model\Source\SortOrder;
use Amasty\Sorting\ViewModel\Helpers;
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Helper\Image;
use Magento\Catalog\Helper\Product\Compare;
use Magento\CatalogWidget\Block\Product\ProductsList;
use Magento\Framework\DB\Select;
class Featured extends ProductsList
{
public const DEFAULT_COLLECTION_SORT_BY = 'name';
public const DEFAULT_COLLECTION_ORDER = SortOrder::SORT_ASC;
public const IMAGE_TYPE = 'featured_products_sidebar';
/**
* @return \Magento\Catalog\Model\ResourceModel\Product\Collection
*/
public function createCollection()
{
$collection = parent::createCollection();
$collection->getSelect()->reset(Select::ORDER);
$collection->setOrder($this->getSortBy(), $this->getSortOrder());
$this->_eventManager->dispatch(
'catalog_block_product_list_collection',
['collection' => $collection]
);
return $collection;
}
/**
* @return string
*/
public function getSortBy()
{
if (!$this->hasData('sort_by')) {
$this->setData('sort_by', self::DEFAULT_COLLECTION_SORT_BY);
}
return $this->getData('sort_by');
}
/**
* @return string
*/
public function getSortOrder()
{
if (!$this->hasData('amsorting_sort_order')) {
$this->setData('amsorting_sort_order', self::DEFAULT_COLLECTION_ORDER);
}
return $this->getData('amsorting_sort_order');
}
/**
* @param ProductInterface $product
* @return Image
*/
public function getImageModel(ProductInterface $product): Image
{
return $this->_imageHelper->init($product, self::IMAGE_TYPE);
}
/**
* @param ProductInterface $product
* @return string
*/
public function getProductName(ProductInterface $product): string
{
/** @var Helpers|null $helper */
$helper = $this->getHelpers();
return $helper
? $helper->getProductAttribute($product, $product->getName(), ProductInterface::NAME)
: '';
}
/**
* @param ProductInterface $product
* @return string
*/
public function getPostData(ProductInterface $product): string
{
/** @var Helpers|null $helper */
$helper = $this->getHelpers();
return $helper
? $helper->getPostData($this->getAddToCartUrl($product), (int) $product->getEntityId())
: '';
}
public function isWishListAllow(): bool
{
/** @var Helpers|null $helper */
$helper = $this->getHelpers();
return $helper ? $helper->getWishlistHelper()->isAllow() : false;
}
private function getHelpers(): ?Helpers
{
return $this->getData('helpers');
}
public function getCompareHelper(): ?Compare
{
/** @var Helpers|null $helper */
$helper = $this->getHelpers();
return $helper ? $helper->getCompareHelper() : null;
}
}