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
@@ -0,0 +1,146 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Block\Adminhtml\Catalog\Product\Edit\Action\Attribute\Tab;
use Magento\Backend\Block\Widget\Tab\TabInterface;
use Magento\Framework\Data\Form\Element\AbstractElement;
class HidePrice extends \Magento\Catalog\Block\Adminhtml\Form implements TabInterface
{
/**
* @var \Magento\Catalog\Model\ProductFactory
*/
protected $_productFactory;
/**
* @var \Magento\Eav\Model\Config
*/
private $eavConfig;
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Framework\Registry $registry,
\Magento\Framework\Data\FormFactory $formFactory,
\Magento\Catalog\Model\ProductFactory $productFactory,
\Magento\Eav\Model\Config $eavConfig,
array $data = []
) {
$this->_productFactory = $productFactory;
parent::__construct($context, $registry, $formFactory, $data);
$this->eavConfig = $eavConfig;
}
/**
* @return void
*/
protected function _construct()
{
parent::_construct();
$this->setShowGlobalIcon(true);
}
/**
* @return $this|void
* @throws \Magento\Framework\Exception\LocalizedException
*/
protected function _prepareForm()
{
/** @var \Magento\Framework\Data\Form $form */
$form = $this->_formFactory->create();
$fieldset = $form->addFieldset('fields', ['legend' => __('Hide Price')]);
$attributes = $this->getAttributes();
/**
* Initialize product object as form property
* for using it in elements generation
*/
$form->setDataObject($this->_productFactory->create());
$this->_setFieldset($attributes, $fieldset, []);
$form->setFieldNameSuffix('attributes');
$this->setForm($form);
}
/**
* Retrieve attributes for product mass update
*
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function getAttributes()
{
$attributes = $this->eavConfig->getEntityType(
\Magento\Catalog\Model\Product::ENTITY
)->getAttributeCollection()->clear()
->addFieldToFilter('attribute_code', ['in' => ['am_hide_price_customer_gr', 'am_hide_price_mode']]);
foreach ($attributes as $attribute) {
$attribute->setIsVisible(true);
if ($attribute->getAttributeCode() == 'am_hide_price_mode') {
$attribute->setSourceModel(\Amasty\HidePrice\Model\Source\PriceMode::class);
}
}
return $attributes;
}
/**
* Custom additional element html
*
* @param AbstractElement $element
* @return string
*/
protected function _getAdditionalElementHtml($element)
{
// Add name attribute to checkboxes that correspond to multiselect elements
$nameAttributeHtml = $element->getExtType() === 'multiple' ? 'name="' . $element->getId() . '_checkbox"' : '';
$elementId = $element->getId();
$dataAttribute = "data-disable='{$elementId}'";
$dataCheckboxName = "toggle_" . "{$elementId}";
$checkboxLabel = __('Change');
$html = <<<HTML
<span class="attribute-change-checkbox">
<input type="checkbox" id="$dataCheckboxName" name="$dataCheckboxName" class="checkbox" $nameAttributeHtml onclick="toogleFieldEditMode(this, '{$elementId}')" $dataAttribute />
<label class="label" for="$dataCheckboxName">
{$checkboxLabel}
</label>
</span>
HTML;
return $html;
}
/**
* @return \Magento\Framework\Phrase
*/
public function getTabLabel()
{
return __('Hide Price');
}
/**
* @return \Magento\Framework\Phrase
*/
public function getTabTitle()
{
return __('Hide Price');
}
/**
* @return bool
*/
public function canShowTab()
{
return true;
}
/**
* @return bool
*/
public function isHidden()
{
return false;
}
}
+28
View File
@@ -0,0 +1,28 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Block\Adminhtml;
class Request extends \Magento\Backend\Block\Widget\Grid\Container
{
/**
* Constructor
*
* @return void
*/
protected function _construct()
{
$this->_controller = 'request';
$this->_headerText = __('Get a Quote Requests');
parent::_construct();
}
protected function _addNewButton()
{
return;//remove new button
}
}
@@ -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\Block\Adminhtml\Request;
use Magento\Backend\Block\Template;
use Amasty\HidePrice\Model\Source\ReplaceButton;
class Comment extends Template
{
/**
* @var \Amasty\HidePrice\Helper\Data
*/
private $helper;
/**
* @var \Magento\Framework\Module\Manager
*/
private $moduleManager;
public function __construct(
\Amasty\HidePrice\Helper\Data $helper,
\Magento\Framework\Module\Manager $moduleManager,
Template\Context $context,
array $data = []
) {
parent::__construct($context, $data);
$this->helper = $helper;
$this->moduleManager = $moduleManager;
}
/**
* @return bool
*/
public function isNeedShow()
{
return $this->moduleManager->isEnabled('Amasty_Customform')
&& $this->helper->getModuleConfig('information/replace_with') == ReplaceButton::CUSTOM_FORM;
}
/**
* @return string
*/
public function getLink()
{
return $this->_urlBuilder->getUrl('amasty_customform/answer/index', [
'form_id' => $this->helper->getModuleConfig('information/custom_form')
]);
}
}
@@ -0,0 +1,198 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Block\Adminhtml\Request\Edit;
class Info extends \Magento\Backend\Block\Template
{
protected $currentRequest;
/**
* @var \Magento\Framework\Registry
*/
private $coreRegistry;
/**
* @var \Magento\Customer\Api\CustomerRepositoryInterface
*/
private $customerRepository;
/**
* @var \Magento\Catalog\Model\ProductRepository
*/
private $productRepository;
/**
* @var \Magento\Store\Model\StoreManagerInterface
*/
private $storeManager;
/**
* @var \Amasty\HidePrice\Model\Source\Status
*/
private $status;
/**
* Info constructor.
* @param \Magento\Backend\Block\Template\Context $context
* @param \Magento\Framework\Registry $coreRegistry
* @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository
* @param \Magento\Catalog\Model\ProductRepository $productRepository
* @param \Amasty\HidePrice\Model\Source\Status $status
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Framework\Registry $coreRegistry,
\Magento\Customer\Api\CustomerRepositoryInterface $customerRepository,
\Magento\Catalog\Model\ProductRepository $productRepository,
\Amasty\HidePrice\Model\Source\Status $status,
array $data = []
) {
$this->coreRegistry = $coreRegistry;
$this->customerRepository = $customerRepository;
$this->productRepository = $productRepository;
$this->storeManager = $context->getStoreManager();
$this->status = $status;
parent::__construct($context, $data);
}
public function _construct()
{
$this->currentRequest = $this->coreRegistry->registry(
\Amasty\HidePrice\Controller\Adminhtml\Request::CURRENT_REQUEST_MODEL
);
parent::_construct();
}
/**
* Add buttons on request view page
* @return $this
*/
protected function _prepareLayout()
{
$button = $this->getLayout()->createBlock(
\Magento\Backend\Block\Widget\Button::class
)->setData(
[
'label' => __('Send Email'),
'class' => 'action-save action-secondary',
'type' => 'submit'
]
);
$this->setChild('submit_button', $button);
$this->getToolbar()->addChild(
'back_button',
\Magento\Backend\Block\Widget\Button::class,
[
'label' => __('Back'),
'onclick' => 'setLocation("' . $this->getUrl('*/*/index') . '")',
'class' => 'back'
]
);
$deleteUrl = $this->getUrl(
'*/*/delete',
['id' => $this->getCurrentRequest()->getRequestId()]
);
$this->getToolbar()->addChild(
'delete_button',
\Magento\Backend\Block\Widget\Button::class,
[
'label' => __('Delete'),
'onclick' => 'deleteConfirm("' . $this->escapeJsQuote(
__(
'You are about to delete this request. '
. 'Are you sure you want to do that?'
)
) . '", "' . $deleteUrl . '")',
'class' => 'delete'
]
);
parent::_prepareLayout();
return $this;
}
/**
* Submit URL getter
*
* @return string
*/
public function getSubmitUrl()
{
return $this->getUrl('*/*/send', ['request_id' => $this->getCurrentRequest()->getRequestId()]);
}
public function getRequestData()
{
/** @var \Amasty\HidePrice\Model\Request $model */
$model = $this->getCurrentRequest();
$customerName = $model->getName();
try {
$customer = $this->customerRepository->get($model->getEmail());
} catch (\Exception $ex) {
$customer = null;
}
if ($customer) {
$customerName = sprintf(
'<a href="%s">%s</a>',
$this->getUrl('customer/index/edit', ['id' => $customer->getId()]),
$customerName
);
}
$productHtml = $model->getProductId();
try {
$product = $this->productRepository->getById($model->getProductId());
} catch (\Exception $ex) {
$product = null;
}
if ($product) {
$productHtml = sprintf(
'<a href="%s">%s</a>',
$this->getUrl('catalog/product/edit', ['id' => $product->getId()]),
$product->getName()
);
}
$store = $this->storeManager->getStore($model->getStore())->getName();
$status = $this->status->getOptionByValue($model->getStatus());
$result = [
['label' => __('Customer Name'), 'value' => $customerName],
['label' => __('Customer Email'), 'value' => $model->getEmail()],
['label' => __('Customer Phone'), 'value' => $model->getPhone()],
['label' => __('Product'), 'value' => $productHtml],
['label' => __('Store'), 'value' => $store],
[
'label' => __('Created'),
'value' => $this->_localeDate->date($model->getCreatedAt())->format('Y-m-d H:i:s')
],
['label' => __('Status'), 'value' => $status],
['label' => __('Comment'), 'value' => $model->getComment()],
];
$answer = $model->getMessageText();
if ($answer) {
$result[] = ['label' => __('Admin Answer Text'), 'value' => $answer];
}
return $result;
}
/**
* @return \Amasty\HidePrice\Model\Request
*/
public function getCurrentRequest()
{
return $this->currentRequest;
}
}
@@ -0,0 +1,166 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Block\Adminhtml\System\Config;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Framework\Module\ModuleListInterface;
class Information extends \Magento\Config\Block\System\Config\Form\Fieldset
{
/**
* @var string
*/
private $userGuide = 'https://amasty.com/docs/doku.php?id=magento_2:hide_price';
/**
* @var array
*/
private $enemyExtensions = [];
/**
* @var string
*/
private $content;
/**
* @var ModuleListInterface
*/
private $moduleList;
public function __construct(
\Magento\Backend\Block\Context $context,
\Magento\Backend\Model\Auth\Session $authSession,
\Magento\Framework\View\Helper\Js $jsHelper,
ModuleListInterface $moduleList,
array $data = []
) {
parent::__construct($context, $authSession, $jsHelper, $data);
$this->moduleList = $moduleList;
}
/**
* 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()
{
$result = '';
if (!class_exists(\Zend_Dom_Query::class)
&& !class_exists(\Zend\Dom\Query::class)
&& !class_exists(\Laminas\Dom\Query::class)
) {
$message = [
'type' => 'message-error',
'text' => __(
'Laminas DOM package is not installed (The package is required for hiding "Add to Cart" '
. 'button on Category Page). Please, run the following command in the SSH: composer require '
. 'laminas/laminas-dom'
)
];
if ($this->getBaseVersion() < '1.3.4') {
return $message['text'];
}
$result = [];
$result[] = $message;
}
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;
}
/**
* @return string
*/
private function getBaseVersion()
{
$version = '';
if (isset($this->moduleList->getOne('Amasty_Base')['setup_version'])) {
$version = $this->moduleList->getOne('Amasty_Base')['setup_version'];
}
return $version;
}
}