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
+101
View File
@@ -0,0 +1,101 @@
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Model\Source;
use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory;
use Magento\Framework\Api\SortOrder;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\Data\OptionSourceInterface;
use Magento\Store\Model\Store;
class Category implements OptionSourceInterface
{
public const NONE = 0;
public const SYSTEM_CATEGORY_ID = 0;
public const ROOT_LEVEL = 0;
/**
* @var CollectionFactory
*/
private $collectionFactory;
/**
* @var RequestInterface
*/
private $request;
public function __construct(
CollectionFactory $collectionFactory,
RequestInterface $request
) {
$this->collectionFactory = $collectionFactory;
$this->request = $request;
}
/**
* Options getter
*
* @return array
*/
public function toOptionArray(): array
{
$optionArray = [];
$arr = $this->toArray();
foreach ($arr as $value => $label) {
$optionArray[] = [
'value' => $value,
'label' => $label
];
}
return $optionArray;
}
/**
* Get options in "key-value" format
*
* @return array
*/
public function toArray(): array
{
return $this->getChildren(self::SYSTEM_CATEGORY_ID, self::ROOT_LEVEL);
}
/**
* @param $parentCategoryId
* @param $level
* @return array
*/
private function getChildren(int $parentCategoryId, int $level)
{
$storeId = (int) $this->request->getParam(Store::ENTITY, Store::DEFAULT_STORE_ID);
$options[self::NONE] = __('None');
$collection = $this->collectionFactory->create();
$collection->setStoreId($storeId);
$collection->addAttributeToSelect('name');
$collection->addAttributeToFilter('level', $level);
$collection->addAttributeToFilter('parent_id', $parentCategoryId);
$collection->setOrder('position', SortOrder::SORT_ASC);
foreach ($collection as $category) {
$options[$category->getId()] =
str_repeat(". ", max(0, ($category->getLevel() - 1) * 3)) . $category->getName();
if ($category->hasChildren()) {
$options = array_replace(
$options,
$this->getChildren((int) $category->getId(), $category->getLevel() + 1)
);
}
}
return $options;
}
}
+47
View File
@@ -0,0 +1,47 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Model\Source;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\Option\ArrayInterface;
use Magento\Framework\DB\Select;
class CustomForm implements ArrayInterface
{
public const CUSTOMFORM_TABLE = 'amasty_customform_form';
/**
* @var ResourceConnection
*/
private $resource;
public function __construct(ResourceConnection $resource)
{
$this->resource = $resource;
}
/**
* @return array
*/
public function toOptionArray()
{
$options = [];
$connection = $this->resource->getConnection();
$tableName = $this->resource->getTableName(self::CUSTOMFORM_TABLE);
if ($connection->isTableExists($tableName)) {
$select = $connection->select()
->from($tableName)
->reset(Select::COLUMNS)
->columns(['value' => 'form_id', 'label' => 'title']);
$options = $connection->fetchAll($select);
}
return $options;
}
}
+77
View File
@@ -0,0 +1,77 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Model\Source;
use Amasty\HidePrice\Helper\Data as Helper;
class Group extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource implements \Magento\Framework\Option\ArrayInterface
{
/**
* @var \Magento\Customer\Model\Customer\Attribute\Source\Group
*/
private $groupSource;
public function __construct(\Magento\Customer\Model\Customer\Attribute\Source\Group $groupSource)
{
$this->groupSource = $groupSource;
}
public function toOptionArray()
{
return array_merge(
[
[
'value' => Helper::DISABLED_GROUP_KEY,
'label' => __('NONE')
],
[
'value' => Helper::NOT_LOGGED_KEY,
'label' => __('NOT LOGGED IN')
]
],
$this->groupSource->getAllOptions()
);
}
/**
* Get options in "key-value" format
*
* @return array
*/
public function toArray()
{
$optionArray = $this->toOptionArray();
$labels = array_column($optionArray, 'label');
$values = array_column($optionArray, 'value');
return array_combine($values, $labels);
}
public function getAllOptions()
{
return $this->toOptionArray();
}
/**
* @return array
*/
public function getFlatColumns()
{
$columns = [];
$columns[$this->getAttribute()->getAttributeCode()] = [
'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
'length' => '255',
'unsigned' => false,
'nullable' => true,
'default' => null,
'extra' => null
];
return $columns;
}
}
+37
View File
@@ -0,0 +1,37 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Model\Source;
class HideButton implements \Magento\Framework\Option\ArrayInterface
{
public const SHOW = 0;
public const HIDE = 1;
public const REPLACE_WITH_NEW_ONE = 2;
/**
* @return array
*/
public function toOptionArray()
{
$options = [
[
'value' => self::SHOW,
'label' => __('No')
],
[
'value' => self::HIDE,
'label' => __('Yes')
],
[
'value' => self::REPLACE_WITH_NEW_ONE,
'label' => __('Replace with custom button')
]
];
return $options;
}
}
+61
View File
@@ -0,0 +1,61 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Model\Source;
class PriceMode implements \Magento\Framework\Option\ArrayInterface
{
public const HIDE = 0;
public const SHOW = 1;
/**
* @return array
*/
public function toOptionArray()
{
$options = [
[
'value' => self::HIDE,
'label' => __('Hide')
],
[
'value' => self::SHOW,
'label' => __('Show')
]
];
return $options;
}
/**
* Rewrite method for using in mass update attribute
* @param $attribute
* @return $this
*/
public function setAttribute($attribute)
{
return $this;
}
/**
* Retrieve Full Option values array
*
* @param bool $withEmpty Add empty option to array
* @param bool $defaultValues
* @return array
*/
public function getAllOptions($withEmpty = true, $defaultValues = false)
{
$options = $this->toOptionArray();
$options[] = [
'value' => '',
'label' => __('-- Default Config --')
];
return $options;
}
}
+54
View File
@@ -0,0 +1,54 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Model\Source;
use Magento\Framework\Module\Manager;
use Magento\Framework\Option\ArrayInterface;
class ReplaceButton implements ArrayInterface
{
public const REDIRECT_URL = 0;
public const HIDE_PRICE_POPUP = 1;
public const CUSTOM_FORM = 2;
/**
* @var Manager
*/
private $moduleManager;
public function __construct(Manager $moduleManager)
{
$this->moduleManager = $moduleManager;
}
/**
* @return array
*/
public function toOptionArray()
{
$options = [
[
'value' => self::REDIRECT_URL,
'label' => __('Link to Custom URL')
],
[
'value' => self::HIDE_PRICE_POPUP,
'label' => __('Amasty Hide Price Popup')
],
[
'value' => self::CUSTOM_FORM,
'label' => __('Popup with Custom Form')
]
];
if ($this->moduleManager->isEnabled('Amasty_Customform') === false) {
$options[self::CUSTOM_FORM]['label'] .= ' (' . __('not installed') . ')';
}
return $options;
}
}
+57
View File
@@ -0,0 +1,57 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Model\Source;
class Status implements \Magento\Framework\Option\ArrayInterface
{
public const PENDING = 0;
public const VIEWED = 1;
public const ANSWERED = 2;
/**
* @var array
*/
protected $options;
/**
* @return array
*/
public function toOptionArray()
{
if (!$this->options) {
$this->options = [
[
'value' => self::PENDING,
'label' => __('Pending')
],
[
'value' => self::VIEWED,
'label' => __('Viewed')
],
[
'value' => self::ANSWERED,
'label' => __('Answered')
]
];
}
return $this->options;
}
public function getOptionByValue($value)
{
$options = $this->toOptionArray();
foreach ($options as $option) {
if ($option['value'] == $value) {
return $option['label'];
}
}
return '';
}
}
+53
View File
@@ -0,0 +1,53 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Model\Source;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Option\ArrayInterface;
use Magento\Eav\Api\AttributeRepositoryInterface;
use Magento\Catalog\Model\Product;
class StockStatus implements ArrayInterface
{
/**
* @var array|null
*/
private $options = null;
/**
* @var AttributeRepositoryInterface
*/
private $attributeRepository;
public function __construct(AttributeRepositoryInterface $attributeRepository)
{
$this->attributeRepository = $attributeRepository;
}
/**
* @return array
*/
public function toOptionArray()
{
if (!isset($this->options)) {
$this->options = [];
try {
$attribute = $this->attributeRepository->get(Product::ENTITY, 'custom_stock_status');
$this->options = $attribute->getSource()->getAllOptions(false);
} catch (NoSuchEntityException $exception) {
$this->options = [];
}
array_unshift($this->options, [
'label' => __('NONE'),
'value' => ''
]);
}
return $this->options;
}
}