ltsecurityinc安防产品在线商城代码
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @author Amasty Team
|
||||
* @copyright Copyright (c) Amasty (https://www.amasty.com)
|
||||
* @package Admin Actions Log for Magento 2
|
||||
*/
|
||||
|
||||
namespace Amasty\AdminActionsLog\Ui\Component\Form;
|
||||
|
||||
use Magento\Framework\View\Element\ComponentVisibilityInterface;
|
||||
|
||||
class CustomerHistoryFieldset extends \Magento\Ui\Component\Form\Fieldset implements ComponentVisibilityInterface
|
||||
{
|
||||
public function isComponentVisible(): bool
|
||||
{
|
||||
return $this->context->getRequestParam('id') !== null;
|
||||
}
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @author Amasty Team
|
||||
* @copyright Copyright (c) Amasty (https://www.amasty.com)
|
||||
* @package Admin Actions Log for Magento 2
|
||||
*/
|
||||
|
||||
namespace Amasty\AdminActionsLog\Ui\Component\Listing\Column;
|
||||
|
||||
use Amasty\AdminActionsLog\Model\OptionSource\LogEntryTypes;
|
||||
use Magento\Framework\View\Element\UiComponent\ContextInterface;
|
||||
use Magento\Framework\View\Element\UiComponentFactory;
|
||||
use Magento\Ui\Component\Listing\Columns\Column;
|
||||
|
||||
class LogEntryActions extends Column
|
||||
{
|
||||
/**
|
||||
* @var LogEntryTypes
|
||||
*/
|
||||
private $logEntryTypes;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $availablePreviewTypes;
|
||||
|
||||
public function __construct(
|
||||
ContextInterface $context,
|
||||
UiComponentFactory $uiComponentFactory,
|
||||
LogEntryTypes $logEntryTypes,
|
||||
array $components = [],
|
||||
array $data = [],
|
||||
array $availablePreviewTypes = []
|
||||
) {
|
||||
parent::__construct($context, $uiComponentFactory, $components, $data);
|
||||
$this->logEntryTypes = $logEntryTypes;
|
||||
$this->availablePreviewTypes = $availablePreviewTypes;
|
||||
}
|
||||
|
||||
public function prepareDataSource(array $dataSource)
|
||||
{
|
||||
$previewTypes = array_filter(array_keys($this->logEntryTypes->toArray()), function ($type) {
|
||||
return in_array($type, $this->availablePreviewTypes);
|
||||
});
|
||||
$dataSource = parent::prepareDataSource($dataSource);
|
||||
|
||||
if (empty($dataSource['data']['items'])) {
|
||||
return $dataSource;
|
||||
}
|
||||
|
||||
foreach ($dataSource['data']['items'] as &$item) {
|
||||
$item[$this->getData('name')]['details'] = [
|
||||
'href' => $this->context->getUrl(
|
||||
'amaudit/actionslog/edit',
|
||||
['id' => $item['id']]
|
||||
),
|
||||
'label' => __('View Details'),
|
||||
'hidden' => false,
|
||||
];
|
||||
|
||||
if (in_array($item['type'], $previewTypes)) {
|
||||
$item[$this->getData('name')]['preview'] = [
|
||||
'callback' => [
|
||||
'provider' => 'index = preview-modal',
|
||||
'target' => 'getPreviewData',
|
||||
'id' => $item['id'],
|
||||
],
|
||||
'label' => __('Preview Details'),
|
||||
'hidden' => false,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $dataSource;
|
||||
}
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @author Amasty Team
|
||||
* @copyright Copyright (c) Amasty (https://www.amasty.com)
|
||||
* @package Admin Actions Log for Magento 2
|
||||
*/
|
||||
|
||||
namespace Amasty\AdminActionsLog\Ui\Component\Listing\Column;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Data\LogEntryInterface;
|
||||
use Amasty\AdminActionsLog\Api\Data\LogEntryInterfaceFactory;
|
||||
use Magento\Backend\Model\UrlInterface;
|
||||
use Magento\Framework\View\Element\UiComponent\ContextInterface;
|
||||
use Magento\Framework\View\Element\UiComponentFactory;
|
||||
use Magento\Ui\Component\Listing\Columns\Column;
|
||||
|
||||
class LogEntryItem extends Column
|
||||
{
|
||||
/**
|
||||
* @var LogEntryInterfaceFactory
|
||||
*/
|
||||
private $logEntryFactory;
|
||||
|
||||
/**
|
||||
* @var UrlInterface
|
||||
*/
|
||||
private $urlBuilder;
|
||||
|
||||
public function __construct(
|
||||
ContextInterface $context,
|
||||
UiComponentFactory $uiComponentFactory,
|
||||
LogEntryInterfaceFactory $logEntryFactory,
|
||||
UrlInterface $urlBuilder,
|
||||
array $components = [],
|
||||
array $data = []
|
||||
) {
|
||||
parent::__construct($context, $uiComponentFactory, $components, $data);
|
||||
$this->logEntryFactory = $logEntryFactory;
|
||||
$this->urlBuilder = $urlBuilder;
|
||||
}
|
||||
|
||||
public function prepareDataSource(array $dataSource)
|
||||
{
|
||||
if (empty($dataSource['data']['items'])) {
|
||||
return $dataSource;
|
||||
}
|
||||
|
||||
foreach ($dataSource['data']['items'] as &$item) {
|
||||
if (isset($item['item'])) {
|
||||
$logEntry = $this->logEntryFactory->create(['data' => $item]);
|
||||
$item['view_url'] = $this->buildViewUrl($logEntry);
|
||||
}
|
||||
}
|
||||
|
||||
return $dataSource;
|
||||
}
|
||||
|
||||
private function buildViewUrl(LogEntryInterface $logEntry): ?string
|
||||
{
|
||||
$category = (string)$logEntry->getCategory();
|
||||
$categoryActionParts = explode('/', $category);
|
||||
|
||||
if (!$logEntry->getElementId() || count($categoryActionParts) < 3) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->urlBuilder->getUrl(
|
||||
$category,
|
||||
[
|
||||
$logEntry->getParameterName() => $logEntry->getViewElementId() ?: $logEntry->getElementId()
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @author Amasty Team
|
||||
* @copyright Copyright (c) Amasty (https://www.amasty.com)
|
||||
* @package Admin Actions Log for Magento 2
|
||||
*/
|
||||
|
||||
namespace Amasty\AdminActionsLog\Ui\Component\Listing\Column;
|
||||
|
||||
use Amasty\AdminActionsLog\Model\ActiveSession\ActiveSession;
|
||||
use Magento\Framework\Stdlib\DateTime\DateTime;
|
||||
use Magento\Framework\View\Element\UiComponent\ContextInterface;
|
||||
use Magento\Framework\View\Element\UiComponentFactory;
|
||||
use Magento\Ui\Component\Listing\Columns\Column;
|
||||
|
||||
class RecentActivity extends Column
|
||||
{
|
||||
public const MINUTE = 60;
|
||||
public const HOUR = 3600;
|
||||
|
||||
/**
|
||||
* @var DateTime
|
||||
*/
|
||||
private $dateTime;
|
||||
|
||||
public function __construct(
|
||||
DateTime $dateTime,
|
||||
ContextInterface $context,
|
||||
UiComponentFactory $uiComponentFactory,
|
||||
array $components = [],
|
||||
array $data = []
|
||||
) {
|
||||
parent::__construct($context, $uiComponentFactory, $components, $data);
|
||||
$this->dateTime = $dateTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $dataSource
|
||||
* @return array
|
||||
*/
|
||||
public function prepareDataSource(array $dataSource): array
|
||||
{
|
||||
if (isset($dataSource['data']['items'])) {
|
||||
foreach ($dataSource['data']['items'] as &$item) {
|
||||
if (isset($item[ActiveSession::RECENT_ACTIVITY])) {
|
||||
$item[ActiveSession::RECENT_ACTIVITY] = $this->decorateRecentActivity(
|
||||
$item[ActiveSession::RECENT_ACTIVITY]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $dataSource;
|
||||
}
|
||||
|
||||
public function decorateRecentActivity(string $rowTime): string
|
||||
{
|
||||
$timeDifference = $this->dateTime->timestamp() - strtotime($rowTime);
|
||||
|
||||
if ($timeDifference < self::MINUTE) {
|
||||
return __('Just Now')->render();
|
||||
} elseif ($timeDifference < self::HOUR) {
|
||||
$minutes = round($timeDifference / self::MINUTE);
|
||||
return __($minutes . " minute(s) ago")->render();
|
||||
} else {
|
||||
$hours = round($timeDifference / self::HOUR);
|
||||
return __($hours . " hour(s) ago")->render();
|
||||
}
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Amasty Team
|
||||
* @copyright Copyright (c) Amasty (https://www.amasty.com)
|
||||
* @package Admin Actions Log for Magento 2
|
||||
*/
|
||||
|
||||
namespace Amasty\AdminActionsLog\Ui\Component\Listing\Column;
|
||||
|
||||
use Magento\Ui\Component\Listing\Columns\Column;
|
||||
|
||||
class ShowHistory extends Column
|
||||
{
|
||||
/**
|
||||
* Prepare Data Source
|
||||
*
|
||||
* @param array $dataSource
|
||||
* @return array
|
||||
*/
|
||||
public function prepareDataSource(array $dataSource)
|
||||
{
|
||||
if (isset($dataSource['data']['items'])) {
|
||||
foreach ($dataSource['data']['items'] as & $item) {
|
||||
$item[$this->getData('name')] = [
|
||||
'history' => [
|
||||
'callback' => [
|
||||
'provider' => 'amaudit_visithistory_listing.amaudit_visithistory_listing.modal',
|
||||
'target' => 'getHistory'
|
||||
],
|
||||
'label' => __('Show History')
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $dataSource;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @author Amasty Team
|
||||
* @copyright Copyright (c) Amasty (https://www.amasty.com)
|
||||
* @package Admin Actions Log for Magento 2
|
||||
*/
|
||||
|
||||
namespace Amasty\AdminActionsLog\Ui\Component\Listing\Column;
|
||||
|
||||
use Magento\Store\Ui\Component\Listing\Column\Store;
|
||||
|
||||
class StoreView extends Store
|
||||
{
|
||||
public function prepareDataSource(array $dataSource)
|
||||
{
|
||||
if (empty($dataSource['data']['items'])) {
|
||||
return $dataSource;
|
||||
}
|
||||
|
||||
foreach ($dataSource['data']['items'] as &$item) {
|
||||
if (isset($item['store_id'])) {
|
||||
$storeId = (int)$item['store_id'];
|
||||
$item['store_id'] = [];
|
||||
$item['store_id'][] = $storeId;
|
||||
}
|
||||
}
|
||||
|
||||
$dataSource = parent::prepareDataSource($dataSource);
|
||||
|
||||
return $dataSource;
|
||||
}
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @author Amasty Team
|
||||
* @copyright Copyright (c) Amasty (https://www.amasty.com)
|
||||
* @package Admin Actions Log for Magento 2
|
||||
*/
|
||||
|
||||
namespace Amasty\AdminActionsLog\Ui\Component\Listing\Column;
|
||||
|
||||
use Amasty\AdminActionsLog\Model\ActiveSession\ActiveSession;
|
||||
use Magento\Framework\UrlInterface;
|
||||
use Magento\Framework\View\Element\UiComponent\ContextInterface;
|
||||
use Magento\Framework\View\Element\UiComponentFactory;
|
||||
use Magento\Ui\Component\Listing\Columns\Column;
|
||||
|
||||
class TerminateAction extends Column
|
||||
{
|
||||
/**
|
||||
* @var UrlInterface
|
||||
*/
|
||||
protected $urlBuilder;
|
||||
|
||||
public function __construct(
|
||||
ContextInterface $context,
|
||||
UiComponentFactory $uiComponentFactory,
|
||||
UrlInterface $urlBuilder,
|
||||
array $components = [],
|
||||
array $data = []
|
||||
) {
|
||||
$this->urlBuilder = $urlBuilder;
|
||||
parent::__construct($context, $uiComponentFactory, $components, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $dataSource
|
||||
* @return array
|
||||
*/
|
||||
public function prepareDataSource(array $dataSource): array
|
||||
{
|
||||
if (isset($dataSource['data']['items'])) {
|
||||
foreach ($dataSource['data']['items'] as &$item) {
|
||||
if (isset($item[$this->getData('config/indexField')])) {
|
||||
$urlEntityParamName = $this->getData('config/urlEntityParamName') ?: 'id';
|
||||
$config = (array)$this->getData('config');
|
||||
if ($config && isset($config['buttons'])) {
|
||||
foreach ($config['buttons'] as $actionName => $button) {
|
||||
$label = $button['itemLabel'];
|
||||
$item[$this->getData('name')][$actionName] = [
|
||||
'href' => $this->urlBuilder->getUrl(
|
||||
$button['urlPath'],
|
||||
[
|
||||
$urlEntityParamName => $item[$this->getData('config/indexField')]
|
||||
]
|
||||
),
|
||||
'label' => __($label)
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $dataSource;
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @author Amasty Team
|
||||
* @copyright Copyright (c) Amasty (https://www.amasty.com)
|
||||
* @package Admin Actions Log for Magento 2
|
||||
*/
|
||||
|
||||
namespace Amasty\AdminActionsLog\Ui\Component\Listing\Filter;
|
||||
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Customer\Customer;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
use Magento\Framework\App\RequestInterface;
|
||||
use Magento\Framework\Data\Collection\AbstractDb;
|
||||
use Magento\Framework\Data\CollectionModifierInterface;
|
||||
|
||||
class FilterCustomerListing implements CollectionModifierInterface
|
||||
{
|
||||
/**
|
||||
* @var RequestInterface
|
||||
*/
|
||||
private $request;
|
||||
|
||||
public function __construct(RequestInterface $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
public function apply(AbstractDb $collection)
|
||||
{
|
||||
$customerId = (int)$this->request->getParam('parent_id');
|
||||
if (!$customerId) {
|
||||
return;
|
||||
}
|
||||
|
||||
$collection->getSelect()->where(sprintf(
|
||||
'main_table.%s = \'%s\' AND main_table.%s = %s',
|
||||
LogEntry::CATEGORY,
|
||||
Customer::CATEGORY,
|
||||
LogEntry::ELEMENT_ID,
|
||||
$customerId
|
||||
));
|
||||
}
|
||||
}
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @author Amasty Team
|
||||
* @copyright Copyright (c) Amasty (https://www.amasty.com)
|
||||
* @package Admin Actions Log for Magento 2
|
||||
*/
|
||||
|
||||
namespace Amasty\AdminActionsLog\Ui\Component\Listing\Filter;
|
||||
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Sales\Creditmemo;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Sales\Invoice;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Sales\Order;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Sales\OrderAddress;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Sales\Shipment;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
use Magento\Framework\App\RequestInterface;
|
||||
use Magento\Framework\Data\Collection\AbstractDb;
|
||||
use Magento\Framework\Data\CollectionModifierInterface;
|
||||
use Magento\Sales\Api\Data\CreditmemoInterface;
|
||||
use Magento\Sales\Api\Data\InvoiceInterface;
|
||||
use Magento\Sales\Api\Data\OrderAddressInterface;
|
||||
use Magento\Sales\Api\Data\OrderInterface;
|
||||
use Magento\Sales\Api\Data\ShipmentInterface;
|
||||
|
||||
class FilterOrderListing implements CollectionModifierInterface
|
||||
{
|
||||
/**
|
||||
* @var RequestInterface
|
||||
*/
|
||||
private $request;
|
||||
|
||||
/**
|
||||
* @var array[]
|
||||
*/
|
||||
private $subEntityConditions = [
|
||||
[
|
||||
'alias' => 'order_table',
|
||||
'table' => 'sales_order',
|
||||
'join_field' => OrderInterface::ENTITY_ID,
|
||||
'entity_field' => OrderInterface::ENTITY_ID,
|
||||
'category' => Order::CATEGORY
|
||||
],
|
||||
[
|
||||
'alias' => 'invoice_table',
|
||||
'table' => 'sales_invoice',
|
||||
'join_field' => InvoiceInterface::ENTITY_ID,
|
||||
'entity_field' => InvoiceInterface::ORDER_ID,
|
||||
'category' => Invoice::CATEGORY
|
||||
],
|
||||
[
|
||||
'alias' => 'shipment_table',
|
||||
'table' => 'sales_shipment',
|
||||
'join_field' => ShipmentInterface::ENTITY_ID,
|
||||
'entity_field' => ShipmentInterface::ORDER_ID,
|
||||
'category' => Shipment::CATEGORY
|
||||
],
|
||||
[
|
||||
'alias' => 'creditmemo_table',
|
||||
'table' => 'sales_creditmemo',
|
||||
'join_field' => CreditmemoInterface::ENTITY_ID,
|
||||
'entity_field' => CreditmemoInterface::ORDER_ID,
|
||||
'category' => Creditmemo::CATEGORY
|
||||
],
|
||||
[
|
||||
'alias' => 'order_address_table',
|
||||
'table' => 'sales_order_address',
|
||||
'join_field' => OrderAddressInterface::ENTITY_ID,
|
||||
'entity_field' => OrderAddressInterface::PARENT_ID,
|
||||
'category' => OrderAddress::CATEGORY
|
||||
]
|
||||
];
|
||||
|
||||
public function __construct(RequestInterface $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
public function apply(AbstractDb $collection)
|
||||
{
|
||||
$sensitiveFields = [];
|
||||
$orderId = (int)$this->request->getParam('order_id');
|
||||
if (!$orderId) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($this->subEntityConditions as $conditionData) {
|
||||
$sensitiveFields[] = $conditionData['alias'] . '.' . $conditionData['join_field'];
|
||||
$collection->getSelect()->joinLeft(
|
||||
[$conditionData['alias'] => $collection->getTable($conditionData['table'])],
|
||||
sprintf(
|
||||
'main_table.%s = %s.%s AND main_table.category = \'%s\' AND %s.%s = %s',
|
||||
LogEntry::ELEMENT_ID,
|
||||
$conditionData['alias'],
|
||||
$conditionData['join_field'],
|
||||
$conditionData['category'],
|
||||
$conditionData['alias'],
|
||||
$conditionData['entity_field'],
|
||||
$orderId
|
||||
),
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
$collection->getSelect()->where(
|
||||
new \Zend_Db_Expr(
|
||||
sprintf('COALESCE (%s) IS NOT NULL', implode(',', $sensitiveFields))
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @author Amasty Team
|
||||
* @copyright Copyright (c) Amasty (https://www.amasty.com)
|
||||
* @package Admin Actions Log for Magento 2
|
||||
*/
|
||||
|
||||
namespace Amasty\AdminActionsLog\Ui\Component\Listing\Filter;
|
||||
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Catalog\Product;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Inventory\Model\SourceItem;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Adminhtml\Stock\Item as StockItem;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
use Magento\Framework\DB\Select;
|
||||
use Magento\Framework\App\RequestInterface;
|
||||
use Magento\Framework\Data\Collection\AbstractDb;
|
||||
use Magento\Framework\Data\CollectionModifierInterface;
|
||||
use Magento\Framework\Exception\NoSuchEntityException;
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
|
||||
class FilterProductListing implements CollectionModifierInterface
|
||||
{
|
||||
/**
|
||||
* @var RequestInterface
|
||||
*/
|
||||
private $request;
|
||||
|
||||
/**
|
||||
* @var ProductRepositoryInterface
|
||||
*/
|
||||
private $productRepository;
|
||||
|
||||
public function __construct(
|
||||
RequestInterface $request,
|
||||
ProductRepositoryInterface $productRepository
|
||||
) {
|
||||
$this->request = $request;
|
||||
$this->productRepository = $productRepository;
|
||||
}
|
||||
|
||||
public function apply(AbstractDb $collection)
|
||||
{
|
||||
$productId = (int)$this->request->getParam('current_product_id');
|
||||
if (!$productId) {
|
||||
return;
|
||||
}
|
||||
|
||||
$collection->getSelect()->where($this->getSqlCondition($productId));
|
||||
}
|
||||
|
||||
private function getSqlCondition(int $productId): string
|
||||
{
|
||||
$sqlCondition = '';
|
||||
|
||||
try {
|
||||
$product = $this->productRepository->getById($productId);
|
||||
} catch (NoSuchEntityException $e) {
|
||||
return 'null';
|
||||
}
|
||||
|
||||
$elements = [
|
||||
[
|
||||
Product::CATEGORY,
|
||||
LogEntry::ELEMENT_ID,
|
||||
(string)$productId
|
||||
], [
|
||||
SourceItem::CATEGORY,
|
||||
LogEntry::ITEM,
|
||||
str_replace("'", "\'", $product->getSku())
|
||||
]
|
||||
];
|
||||
|
||||
if ($product->getExtensionAttributes()
|
||||
&& $stockItem = $product->getExtensionAttributes()->getStockItem()
|
||||
) {
|
||||
$elements[] = [
|
||||
StockItem::CATEGORY,
|
||||
LogEntry::ELEMENT_ID,
|
||||
(string)$stockItem->getItemId()
|
||||
];
|
||||
}
|
||||
|
||||
$lastIndex = count($elements) - 1;
|
||||
|
||||
foreach ($elements as $index => $element) {
|
||||
$sqlCondition .= sprintf('(%s)', $this->prepareSql(...$element));
|
||||
|
||||
if ($index !== $lastIndex) {
|
||||
$sqlCondition .= sprintf(' %s ', Select::SQL_OR);
|
||||
}
|
||||
}
|
||||
|
||||
return $sqlCondition;
|
||||
}
|
||||
|
||||
private function prepareSql(
|
||||
string $category,
|
||||
string $identifierFieldName,
|
||||
string $identifier
|
||||
): string {
|
||||
return sprintf(
|
||||
'main_table.%s = \'%s\' AND main_table.%s = \'%s\'',
|
||||
LogEntry::CATEGORY,
|
||||
$category,
|
||||
$identifierFieldName,
|
||||
$identifier
|
||||
);
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @author Amasty Team
|
||||
* @copyright Copyright (c) Amasty (https://www.amasty.com)
|
||||
* @package Admin Actions Log for Magento 2
|
||||
*/
|
||||
|
||||
namespace Amasty\AdminActionsLog\Ui\Component\Listing\MassActions;
|
||||
|
||||
use Amasty\AdminActionsLog\Model\ConfigProvider;
|
||||
use Magento\Framework\View\Element\UiComponent\ContextInterface;
|
||||
use Magento\Ui\Component\Action;
|
||||
|
||||
class Restore extends Action
|
||||
{
|
||||
/**
|
||||
* @var ConfigProvider
|
||||
*/
|
||||
private $configProvider;
|
||||
|
||||
public function __construct(
|
||||
ContextInterface $context,
|
||||
ConfigProvider $configProvider,
|
||||
array $components = [],
|
||||
array $data = [],
|
||||
$actions = null
|
||||
) {
|
||||
parent::__construct($context, $components, $data, $actions);
|
||||
$this->configProvider = $configProvider;
|
||||
}
|
||||
|
||||
public function getConfiguration()
|
||||
{
|
||||
$config = parent::getConfiguration();
|
||||
$config['confirm']['message'] = $this->configProvider->getRestoreSettingsText()
|
||||
. ' ' . __('Are you sure you want to restore selected items?');
|
||||
|
||||
return $config;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user