ltsecurityinc安防产品在线商城代码
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
<?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\Logging\Entity\SaveHandler\Admin;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Logging\Util\Ignore\ArrayFilter;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
use Magento\User\Model\UserFactory;
|
||||
|
||||
class User extends Common
|
||||
{
|
||||
/**
|
||||
* @var UserFactory
|
||||
*/
|
||||
private $userFactory;
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected $dataKeysIgnoreList = [
|
||||
'reload_acl_flag',
|
||||
'modified'
|
||||
];
|
||||
|
||||
public function __construct(
|
||||
ArrayFilter\ScalarValueFilter $scalarValueFilter,
|
||||
ArrayFilter\KeyFilter $keyFilter,
|
||||
UserFactory $userFactory
|
||||
) {
|
||||
parent::__construct($scalarValueFilter, $keyFilter);
|
||||
$this->userFactory = $userFactory;
|
||||
}
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var \Magento\User\Model\User $adminUser */
|
||||
$adminUser = $metadata->getObject();
|
||||
|
||||
if (!$adminUser->getUserName()) {
|
||||
$adminUser->load($adminUser->getId());
|
||||
}
|
||||
|
||||
return [
|
||||
LogEntry::ITEM => $adminUser->getUserName(),
|
||||
LogEntry::CATEGORY => 'admin/user/edit',
|
||||
LogEntry::CATEGORY_NAME => __('Admin User'),
|
||||
LogEntry::ELEMENT_ID => (int)$adminUser->getId(),
|
||||
LogEntry::PARAMETER_NAME => 'user_id'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Magento\User\Model\User $object
|
||||
* @return array
|
||||
*/
|
||||
public function processBeforeSave($object): array
|
||||
{
|
||||
if ($role = $object->getRole()) {
|
||||
$object->setOrigData('role_id', $role->getId());
|
||||
}
|
||||
|
||||
return parent::processBeforeSave($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Magento\User\Model\User $object
|
||||
* @return array
|
||||
*/
|
||||
public function processAfterSave($object): array
|
||||
{
|
||||
$user = $this->userFactory->create()->load($object->getId());
|
||||
|
||||
if ($role = $user->getRole()) {
|
||||
$user->setRoleId($role->getId());
|
||||
}
|
||||
|
||||
return parent::processAfterSave($user);
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
<?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\Logging\Entity\SaveHandler\Admin;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
use Amasty\AdminActionsLog\Model\OptionSource\LogEntryTypes;
|
||||
|
||||
class UserExpiration extends Common
|
||||
{
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var \Magento\Security\Model\UserExpiration $expiration */
|
||||
$expiration = $metadata->getObject();
|
||||
$type = $expiration->getOrigData() === [] ? LogEntryTypes::TYPE_NEW : LogEntryTypes::TYPE_EDIT;
|
||||
|
||||
return [
|
||||
LogEntry::TYPE => $type,
|
||||
LogEntry::ITEM => __('Expiration for Admin #%1', $expiration->getUserId()),
|
||||
LogEntry::CATEGORY => 'admin/user/edit',
|
||||
LogEntry::CATEGORY_NAME => __('Admin Expiration'),
|
||||
LogEntry::ELEMENT_ID => (int)$expiration->getUserId(),
|
||||
LogEntry::PARAMETER_NAME => 'user_id'
|
||||
];
|
||||
}
|
||||
|
||||
public function processAfterSave($object): array
|
||||
{
|
||||
$object->load($object->getId());
|
||||
|
||||
return parent::processAfterSave($object);
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
<?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\Logging\Entity\SaveHandler\Admin;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
|
||||
class UserRole extends Common
|
||||
{
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var \Magento\Authorization\Model\Role $role */
|
||||
$role = $metadata->getObject();
|
||||
|
||||
return [
|
||||
LogEntry::ITEM => $role->getRoleName(),
|
||||
LogEntry::CATEGORY => 'admin/user_role/editrole',
|
||||
LogEntry::CATEGORY_NAME => __('Admin User Role'),
|
||||
LogEntry::ELEMENT_ID => (int)$role->getId(),
|
||||
LogEntry::PARAMETER_NAME => 'rid'
|
||||
];
|
||||
}
|
||||
}
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
<?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\Logging\Entity\SaveHandler\Adminhtml\Stock;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Logging\Util\Ignore\ArrayFilter;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
use Magento\CatalogInventory\Api\StockItemRepositoryInterface;
|
||||
use Magento\CatalogInventory\Model\Adminhtml\Stock\Item as StockItem;
|
||||
|
||||
class Item extends Common
|
||||
{
|
||||
public const CATEGORY = 'catalog/product/edit/stock/item';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $stockItems = [];
|
||||
|
||||
/**
|
||||
* @var ProductRepositoryInterface
|
||||
*/
|
||||
private $productRepository;
|
||||
|
||||
/**
|
||||
* @var StockItemRepositoryInterface
|
||||
*/
|
||||
private $stockItemRepository;
|
||||
|
||||
public function __construct(
|
||||
ArrayFilter\ScalarValueFilter $scalarValueFilter,
|
||||
ArrayFilter\KeyFilter $keyFilter,
|
||||
ProductRepositoryInterface $productRepository,
|
||||
StockItemRepositoryInterface $stockItemRepository
|
||||
) {
|
||||
parent::__construct($scalarValueFilter, $keyFilter);
|
||||
$this->productRepository = $productRepository;
|
||||
$this->stockItemRepository = $stockItemRepository;
|
||||
}
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var StockItem $stockItem */
|
||||
$stockItem = $metadata->getObject();
|
||||
$product = $this->productRepository->getById((int)$stockItem->getProductId());
|
||||
|
||||
return [
|
||||
LogEntry::ITEM => $product->getName(),
|
||||
LogEntry::CATEGORY => self::CATEGORY,
|
||||
LogEntry::CATEGORY_NAME => __('Stock Item'),
|
||||
LogEntry::ELEMENT_ID => $stockItem->getId(),
|
||||
LogEntry::VIEW_ELEMENT_ID => $product->getId(),
|
||||
];
|
||||
}
|
||||
|
||||
public function processBeforeSave($object): array
|
||||
{
|
||||
$stockItem = $this->getStockItem((int)$object->getId());
|
||||
|
||||
return $this->filterObjectData($stockItem->getData());
|
||||
}
|
||||
|
||||
private function getStockItem(int $stockItemId): StockItem
|
||||
{
|
||||
if (!isset($this->stockItems[$stockItemId])) {
|
||||
$this->stockItems[$stockItemId] = $this->stockItemRepository->get($stockItemId);
|
||||
}
|
||||
|
||||
return $this->stockItems[$stockItemId];
|
||||
}
|
||||
}
|
||||
Executable
+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\Logging\Entity\SaveHandler\Amasty\RequestQuote\Model;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Logging\Util\Ignore\ArrayFilter;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
|
||||
class Quote extends Common
|
||||
{
|
||||
public const CATEGORY = 'amasty_quote/quote/view';
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private $keysToCheck;
|
||||
|
||||
public function __construct(
|
||||
ArrayFilter\ScalarValueFilter $scalarValueFilter,
|
||||
ArrayFilter\KeyFilter $keyFilter,
|
||||
array $keysToCheck = []
|
||||
) {
|
||||
parent::__construct($scalarValueFilter, $keyFilter);
|
||||
$this->keysToCheck = $keysToCheck;
|
||||
}
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var \Amasty\RequestQuote\Model\Quote $quote */
|
||||
$quote = $metadata->getObject();
|
||||
|
||||
return [
|
||||
LogEntry::ITEM => __('Request Quote #%1', $quote->getIncrementId()),
|
||||
LogEntry::CATEGORY => self::CATEGORY,
|
||||
LogEntry::CATEGORY_NAME => __('Request Quote'),
|
||||
LogEntry::ELEMENT_ID => $quote->getId(),
|
||||
LogEntry::PARAMETER_NAME => 'quote_id'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Amasty\RequestQuote\Model\Quote $object
|
||||
* @return array
|
||||
*/
|
||||
public function processBeforeSave($object): array
|
||||
{
|
||||
$quote = clone $object;
|
||||
$quote->load($object->getId());
|
||||
|
||||
return $this->filterObjectData((array)$quote->getData());
|
||||
}
|
||||
|
||||
protected function filterObjectData(array $data): array
|
||||
{
|
||||
$data = parent::filterObjectData($data);
|
||||
|
||||
return array_intersect_key($data, array_flip($this->keysToCheck));
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
<?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\Logging\Entity\SaveHandler\Catalog;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
|
||||
class Category extends Common
|
||||
{
|
||||
public const CATEGORY = 'catalog/category/edit';
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected $dataKeysIgnoreList = [
|
||||
'form_key',
|
||||
'entity_id',
|
||||
'updated_at',
|
||||
'url_key_create_redirect',
|
||||
'save_rewrites_history',
|
||||
'custom_design_from_is_formated'
|
||||
];
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var \Magento\Catalog\Model\Category $category */
|
||||
$category = $metadata->getObject();
|
||||
|
||||
if (!$category->getName()) {
|
||||
$category->load($category->getId()); // Force reload category in cases of mass delete, etc.
|
||||
}
|
||||
|
||||
return [
|
||||
LogEntry::ITEM => $category->getName(),
|
||||
LogEntry::CATEGORY => self::CATEGORY,
|
||||
LogEntry::CATEGORY_NAME => __('Catalog Category'),
|
||||
LogEntry::ELEMENT_ID => (int)$category->getId(),
|
||||
LogEntry::STORE_ID => (int)$category->getStoreId()
|
||||
];
|
||||
}
|
||||
}
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
<?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\Logging\Entity\SaveHandler\Catalog;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Logging\Util\Ignore\ArrayFilter;
|
||||
use Amasty\AdminActionsLog\Model\Catalog\Model\Product\Gallery\LogImages;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
use Magento\Framework\App\ObjectManager;
|
||||
|
||||
class Product extends Common
|
||||
{
|
||||
public const CATEGORY = 'catalog/product/edit';
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected $dataKeysIgnoreList = [
|
||||
'current_product_id',
|
||||
'affect_product_custom_options',
|
||||
'current_store_id',
|
||||
'product_has_weight',
|
||||
'is_new',
|
||||
'_edit_mode',
|
||||
'amrolepermissions_owner',
|
||||
'use_config_gift_message_available',
|
||||
'use_config_gift_wrapping_available',
|
||||
'url_key_create_redirect',
|
||||
'use_config_is_returnable',
|
||||
'can_save_custom_options',
|
||||
'save_rewrites_history',
|
||||
'is_custom_option_changed',
|
||||
'special_from_date_is_formated',
|
||||
'custom_design_from_is_formated',
|
||||
'news_from_date_is_formated',
|
||||
'news_to_date_is_formated',
|
||||
'force_reindex_eav_required',
|
||||
'updated_at',
|
||||
'has_options',
|
||||
'required_options',
|
||||
'quantity_and_stock_status'
|
||||
];
|
||||
|
||||
/**
|
||||
* @var LogImages
|
||||
*/
|
||||
private $logImages;
|
||||
|
||||
public function __construct(
|
||||
ArrayFilter\ScalarValueFilter $scalarValueFilter,
|
||||
ArrayFilter\KeyFilter $keyFilter,
|
||||
?LogImages $logImages = null
|
||||
) {
|
||||
parent::__construct($scalarValueFilter, $keyFilter);
|
||||
$this->logImages = $logImages ?? ObjectManager::getInstance()->get(LogImages::class);
|
||||
}
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var \Magento\Catalog\Model\Product $product */
|
||||
$product = $metadata->getObject();
|
||||
|
||||
if (!$product->getName()) {
|
||||
$product->load($product->getId()); // Force reload product in cases of mass delete, etc.
|
||||
}
|
||||
|
||||
return [
|
||||
LogEntry::ITEM => $product->getName(),
|
||||
LogEntry::CATEGORY => self::CATEGORY,
|
||||
LogEntry::CATEGORY_NAME => __('Catalog Product'),
|
||||
LogEntry::ELEMENT_ID => (int)$product->getId(),
|
||||
LogEntry::STORE_ID => (int)$product->getStoreId()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Magento\Framework\Model\AbstractModel $object
|
||||
* @return array
|
||||
*/
|
||||
public function processBeforeSave($object): array
|
||||
{
|
||||
$this->logImages->processGalleryBeforeSave($object);
|
||||
|
||||
return parent::processBeforeSave($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Magento\Framework\Model\AbstractModel $object
|
||||
* @return array
|
||||
*/
|
||||
public function processAfterSave($object): array
|
||||
{
|
||||
$this->logImages->processGalleryAfterSave($object);
|
||||
|
||||
return parent::processAfterSave($object);
|
||||
}
|
||||
}
|
||||
Executable
+52
@@ -0,0 +1,52 @@
|
||||
<?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\Logging\Entity\SaveHandler\Catalog;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
|
||||
class ProductGalleryEntry extends Common
|
||||
{
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
$image = $metadata->getObject();
|
||||
|
||||
return [
|
||||
LogEntry::ITEM => $image->getFile(),
|
||||
LogEntry::CATEGORY => __('Product Gallery Image'),
|
||||
LogEntry::CATEGORY_NAME => __('Product Gallery Image'),
|
||||
LogEntry::ELEMENT_ID => (int)$image->getId()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Magento\Framework\Model\AbstractModel $object
|
||||
* @return array
|
||||
*/
|
||||
public function processBeforeSave($object): array
|
||||
{
|
||||
if ($object->getId()) {
|
||||
return $this->filterObjectData($object->getData());
|
||||
} else {
|
||||
return $this->filterObjectData((array)$object->getOrigData());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Magento\Framework\Model\AbstractModel $object
|
||||
* @return array
|
||||
*/
|
||||
public function processAfterSave($object): array
|
||||
{
|
||||
return $this->filterObjectData($object->getData());
|
||||
}
|
||||
}
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
<?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\Logging\Entity\SaveHandler\Catalog;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Logging\Util\Ignore\ArrayFilter;
|
||||
use Amasty\AdminActionsLog\Logging\Util\ProductIdentifierResolver;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
use Amasty\AdminActionsLog\Model\OptionSource\LogEntryTypes;
|
||||
use Magento\Catalog\Api\ProductCustomOptionRepositoryInterface;
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
|
||||
class ProductOption extends Common
|
||||
{
|
||||
public const CATEGORY = 'catalog/product/edit';
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected $dataKeysIgnoreList = [
|
||||
'is_use_default',
|
||||
'initialize',
|
||||
'record_id',
|
||||
'product_sku',
|
||||
'store_id'
|
||||
];
|
||||
|
||||
/**
|
||||
* @var ProductRepositoryInterface
|
||||
*/
|
||||
private $productRepository;
|
||||
|
||||
/**
|
||||
* @var ProductCustomOptionRepositoryInterface
|
||||
*/
|
||||
private $productCustomOptionRepository;
|
||||
|
||||
/**
|
||||
* @var ProductIdentifierResolver
|
||||
*/
|
||||
private $productIdentifierResolver;
|
||||
|
||||
public function __construct(
|
||||
ArrayFilter\ScalarValueFilter $scalarValueFilter,
|
||||
ArrayFilter\KeyFilter $keyFilter,
|
||||
ProductRepositoryInterface $productRepository,
|
||||
ProductCustomOptionRepositoryInterface $productCustomOptionRepository,
|
||||
ProductIdentifierResolver $productIdentifierResolver
|
||||
) {
|
||||
parent::__construct($scalarValueFilter, $keyFilter);
|
||||
|
||||
$this->productRepository = $productRepository;
|
||||
$this->productCustomOptionRepository = $productCustomOptionRepository;
|
||||
$this->productIdentifierResolver = $productIdentifierResolver;
|
||||
}
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var \Magento\Catalog\Model\Product\Option $option */
|
||||
$option = $metadata->getObject();
|
||||
$type = $option->isObjectNew() ? LogEntryTypes::TYPE_NEW : LogEntryTypes::TYPE_EDIT;
|
||||
// Workaround because there is no product SKU in the object when deleted
|
||||
$productId = $this->productIdentifierResolver->execute((int)$option->getProductId());
|
||||
|
||||
return [
|
||||
LogEntry::TYPE => $type,
|
||||
LogEntry::ITEM => __('Option "%1"', $option->getTitle()),
|
||||
LogEntry::CATEGORY => self::CATEGORY,
|
||||
LogEntry::CATEGORY_NAME => __('Product Customizable Option'),
|
||||
LogEntry::ELEMENT_ID => $productId,
|
||||
LogEntry::STORE_ID => (int)$option->getStoreId(),
|
||||
LogEntry::ADDITIONAL_DATA => [
|
||||
'productId' => $productId,
|
||||
'optionId' => $option->getId() ? (int)$option->getId() : null
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function processBeforeSave($object): array
|
||||
{
|
||||
if ($object->getId()) {
|
||||
$productId = $this->productIdentifierResolver->execute((int)$object->getProductId());
|
||||
$product = $this->productRepository->getById($productId, false, (int)$object->getStoreId());
|
||||
$option = $this->productCustomOptionRepository->getProductOptions($product)
|
||||
[$object->getId()] ?? null;
|
||||
|
||||
return $option ? $this->filterObjectData($option->getData()) : [];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function processAfterSave($object): array
|
||||
{
|
||||
$data = parent::processAfterSave($object);
|
||||
if ($object->hasValues()) {
|
||||
unset($data['price_type']);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
Executable
+121
@@ -0,0 +1,121 @@
|
||||
<?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\Logging\Entity\SaveHandler\Catalog;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Api\Logging\ObjectDataStorageInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Logging\Util\Ignore\ArrayFilter;
|
||||
use Amasty\AdminActionsLog\Logging\Util\ProductIdentifierResolver;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
use Amasty\AdminActionsLog\Model\OptionSource\LogEntryTypes;
|
||||
use Amasty\AdminActionsLog\Restoring\Entity\RestoreHandler\AbstractHandler;
|
||||
use Magento\Catalog\Api\ProductCustomOptionRepositoryInterface;
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
|
||||
class ProductOptionValue extends Common
|
||||
{
|
||||
public const CATEGORY = 'catalog/product/edit';
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected $dataKeysIgnoreList = [
|
||||
'is_use_default',
|
||||
'initialize',
|
||||
'record_id',
|
||||
'store_id'
|
||||
];
|
||||
|
||||
/**
|
||||
* @var ProductRepositoryInterface
|
||||
*/
|
||||
private $productRepository;
|
||||
|
||||
/**
|
||||
* @var ProductCustomOptionRepositoryInterface
|
||||
*/
|
||||
private $productCustomOptionRepository;
|
||||
|
||||
/**
|
||||
* @var ProductIdentifierResolver
|
||||
*/
|
||||
private $productIdentifierResolver;
|
||||
|
||||
/**
|
||||
* @var ObjectDataStorageInterface
|
||||
*/
|
||||
private $dataStorage;
|
||||
|
||||
public function __construct(
|
||||
ArrayFilter\ScalarValueFilter $scalarValueFilter,
|
||||
ArrayFilter\KeyFilter $keyFilter,
|
||||
ProductRepositoryInterface $productRepository,
|
||||
ProductCustomOptionRepositoryInterface $productCustomOptionRepository,
|
||||
ProductIdentifierResolver $productIdentifierResolver,
|
||||
ObjectDataStorageInterface $dataStorage
|
||||
) {
|
||||
parent::__construct($scalarValueFilter, $keyFilter);
|
||||
|
||||
$this->productRepository = $productRepository;
|
||||
$this->productCustomOptionRepository = $productCustomOptionRepository;
|
||||
$this->productIdentifierResolver = $productIdentifierResolver;
|
||||
$this->dataStorage = $dataStorage;
|
||||
}
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var \Magento\Catalog\Model\Product\Option\Value $value */
|
||||
$value = $metadata->getObject();
|
||||
// Workaround because there is no product SKU in the object when deleted
|
||||
$productId = $this->productIdentifierResolver->execute((int)$value->getOption()->getProductId());
|
||||
$type = $value->isObjectNew() ? LogEntryTypes::TYPE_NEW : LogEntryTypes::TYPE_EDIT;
|
||||
$storageKey = spl_object_id($value->getOption()) . '.' . AbstractHandler::STORAGE_CODE_PREFIX;
|
||||
if ($this->dataStorage->isExists($storageKey)) {
|
||||
$type = LogEntryTypes::TYPE_RESTORE;
|
||||
}
|
||||
|
||||
return [
|
||||
LogEntry::TYPE => $type,
|
||||
LogEntry::ITEM => __(
|
||||
'Value "%1" of Option "%2"',
|
||||
$value->getTitle(),
|
||||
$value->getOption()->getTitle()
|
||||
),
|
||||
LogEntry::CATEGORY => self::CATEGORY,
|
||||
LogEntry::CATEGORY_NAME => __('Product Customizable Option'),
|
||||
LogEntry::ELEMENT_ID => $productId,
|
||||
LogEntry::STORE_ID => (int)$value->getStoreId(),
|
||||
LogEntry::ADDITIONAL_DATA => [
|
||||
'productId' => $productId,
|
||||
'optionId' => $value->getOption()->getId(),
|
||||
'valueId' => $value->getId() ? (int)$value->getId() : null
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function processBeforeSave($object): array
|
||||
{
|
||||
if ($object->getId() && $object->getOption()->getId()) {
|
||||
$productId = $this->productIdentifierResolver->execute(
|
||||
(int)$object->getOption()->getProductId()
|
||||
);
|
||||
$product = $this->productRepository->getById($productId, false, (int)$object->getStoreId());
|
||||
$option = $this->productCustomOptionRepository->getProductOptions($product)
|
||||
[$object->getOption()->getId()] ?? null;
|
||||
$value = $option ? $option->getValues()[$object->getId()] ?? null : null;
|
||||
|
||||
return $value ? $this->filterObjectData($value->getData()) : [];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
Executable
+69
@@ -0,0 +1,69 @@
|
||||
<?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\Logging\Entity\SaveHandler\CheckoutAgreement;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Logging\Util\Ignore\ArrayFilter;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
use Magento\CheckoutAgreements\Api\CheckoutAgreementsRepositoryInterface;
|
||||
use Magento\CheckoutAgreements\Model\Agreement as CheckoutAgreement;
|
||||
|
||||
class Agreement extends Common
|
||||
{
|
||||
public const CATEGORY = 'checkout/agreement/edit';
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected $dataKeysIgnoreList = [
|
||||
'form_key'
|
||||
];
|
||||
|
||||
/**
|
||||
* @var CheckoutAgreementsRepositoryInterface
|
||||
*/
|
||||
private $checkoutAgreementsRepository;
|
||||
|
||||
public function __construct(
|
||||
ArrayFilter\ScalarValueFilter $scalarValueFilter,
|
||||
ArrayFilter\KeyFilter $keyFilter,
|
||||
CheckoutAgreementsRepositoryInterface $checkoutAgreementsRepository
|
||||
) {
|
||||
parent::__construct($scalarValueFilter, $keyFilter);
|
||||
|
||||
$this->checkoutAgreementsRepository = $checkoutAgreementsRepository;
|
||||
}
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var CheckoutAgreement $agreement */
|
||||
$agreement = $metadata->getObject();
|
||||
|
||||
return [
|
||||
LogEntry::ITEM => $agreement->getName(),
|
||||
LogEntry::CATEGORY => self::CATEGORY,
|
||||
LogEntry::CATEGORY_NAME => __('Terms and Conditions'),
|
||||
LogEntry::ELEMENT_ID => (int)$agreement->getId(),
|
||||
];
|
||||
}
|
||||
|
||||
public function processBeforeSave($object): array
|
||||
{
|
||||
if ($object->getId()) {
|
||||
$agreement = $this->checkoutAgreementsRepository->get((int)$object->getId());
|
||||
|
||||
return $this->filterObjectData($agreement->getData());
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?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\Logging\Entity\SaveHandler\Cms;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
use Magento\Store\Model\Store;
|
||||
|
||||
class Block extends Common
|
||||
{
|
||||
public const CATEGORY = 'cms/block/edit';
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected $dataKeysIgnoreList = [
|
||||
'_first_store_id',
|
||||
'form_key',
|
||||
];
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var \Magento\Cms\Model\Block $block */
|
||||
$block = $metadata->getObject();
|
||||
|
||||
return [
|
||||
LogEntry::ITEM => $block->getTitle(),
|
||||
LogEntry::CATEGORY => self::CATEGORY,
|
||||
LogEntry::CATEGORY_NAME => __('CMS Block'),
|
||||
LogEntry::ELEMENT_ID => (int)$block->getId(),
|
||||
LogEntry::STORE_ID => Store::DEFAULT_STORE_ID,
|
||||
LogEntry::PARAMETER_NAME => 'block_id'
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?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\Logging\Entity\SaveHandler\Cms;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
use Magento\Store\Model\Store;
|
||||
|
||||
class Page extends Common
|
||||
{
|
||||
public const CATEGORY = 'admin/cms_page/edit/';
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var \Magento\Cms\Model\Page $page */
|
||||
$page = $metadata->getObject();
|
||||
|
||||
return [
|
||||
LogEntry::ITEM => $page->getTitle(),
|
||||
LogEntry::CATEGORY => self::CATEGORY,
|
||||
LogEntry::CATEGORY_NAME => __('CMS Page'),
|
||||
LogEntry::ELEMENT_ID => (int)$page->getId(),
|
||||
LogEntry::STORE_ID => Store::DEFAULT_STORE_ID,
|
||||
LogEntry::PARAMETER_NAME => 'page_id'
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?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\Logging\Entity\SaveHandler\Cms;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
use Magento\Store\Model\Store;
|
||||
|
||||
class Widget extends Common
|
||||
{
|
||||
public const CATEGORY = 'admin/widget_instance/edit/';
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var \Magento\Widget\Model\Widget\Instance $widget */
|
||||
$widget = $metadata->getObject();
|
||||
|
||||
return [
|
||||
LogEntry::ITEM => $widget->getTitle(),
|
||||
LogEntry::CATEGORY => self::CATEGORY,
|
||||
LogEntry::CATEGORY_NAME => __('CMS Widget'),
|
||||
LogEntry::ELEMENT_ID => (int)$widget->getId(),
|
||||
LogEntry::STORE_ID => Store::DEFAULT_STORE_ID,
|
||||
LogEntry::PARAMETER_NAME => 'instance_id'
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
<?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\Logging\Entity\SaveHandler;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\EntitySaveHandlerInterface;
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Util\Ignore\ArrayFilter;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
|
||||
class Common implements EntitySaveHandlerInterface
|
||||
{
|
||||
/**
|
||||
* @var ArrayFilter\ScalarValueFilter
|
||||
*/
|
||||
private $scalarValueFilter;
|
||||
|
||||
/**
|
||||
* @var ArrayFilter\KeyFilter
|
||||
*/
|
||||
private $keyFilter;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $dataKeysIgnoreList = [];
|
||||
|
||||
public function __construct(
|
||||
ArrayFilter\ScalarValueFilter $scalarValueFilter,
|
||||
ArrayFilter\KeyFilter $keyFilter
|
||||
) {
|
||||
$this->scalarValueFilter = $scalarValueFilter;
|
||||
$this->keyFilter = $keyFilter;
|
||||
}
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var \Magento\Framework\Model\AbstractModel $object */
|
||||
$object = $metadata->getObject();
|
||||
|
||||
return [
|
||||
LogEntry::ELEMENT_ID => (int)$object->getId(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Magento\Framework\Model\AbstractModel $object
|
||||
* @return array
|
||||
*/
|
||||
public function processBeforeSave($object): array
|
||||
{
|
||||
if (!$object instanceof \Magento\Framework\Model\AbstractModel) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $this->filterObjectData((array)$object->getOrigData());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Magento\Framework\Model\AbstractModel $object
|
||||
* @return array
|
||||
*/
|
||||
public function processAfterSave($object): array
|
||||
{
|
||||
if (!$object instanceof \Magento\Framework\Model\AbstractModel) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $this->filterObjectData((array)$object->getData());
|
||||
}
|
||||
|
||||
protected function filterObjectData(array $data): array
|
||||
{
|
||||
$data = $this->scalarValueFilter->filter($data);
|
||||
$data = $this->keyFilter->filter($data, $this->dataKeysIgnoreList ?? []);
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
<?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\Logging\Entity\SaveHandler;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\EntitySaveHandlerInterface;
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
use Amasty\AdminActionsLog\Model\OptionSource\LogEntryTypes;
|
||||
use Amasty\Base\Model\Serializer;
|
||||
use Magento\Framework\App\Config\ScopeConfigInterface;
|
||||
use Magento\Framework\App\Config\Value;
|
||||
use Magento\Store\Model\ScopeInterface;
|
||||
|
||||
class Config implements EntitySaveHandlerInterface
|
||||
{
|
||||
/**
|
||||
* @var ScopeConfigInterface
|
||||
*/
|
||||
private $scopeConfig;
|
||||
|
||||
/**
|
||||
* @var Serializer
|
||||
*/
|
||||
private $serializer;
|
||||
|
||||
public function __construct(
|
||||
ScopeConfigInterface $scopeConfig,
|
||||
Serializer $serializer
|
||||
) {
|
||||
$this->scopeConfig = $scopeConfig;
|
||||
$this->serializer = $serializer;
|
||||
}
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var Value $object */
|
||||
$object = $metadata->getObject();
|
||||
|
||||
return [
|
||||
LogEntry::TYPE => LogEntryTypes::TYPE_EDIT,
|
||||
LogEntry::CATEGORY_NAME => __('System Config'),
|
||||
LogEntry::ELEMENT_ID => (int)$object->getId(),
|
||||
LogEntry::STORE_ID => (int)$object->getScopeId(),
|
||||
// save 'scope' in additional data to understand, what we save in 'store_id': website id or store view id.
|
||||
LogEntry::ADDITIONAL_DATA => [
|
||||
'scope' => $object->getScope()
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Value $object
|
||||
* @return array
|
||||
*/
|
||||
public function processBeforeSave($object): array
|
||||
{
|
||||
$oldValue = $this->scopeConfig->getValue(
|
||||
$object->getPath(),
|
||||
$object->getScope(),
|
||||
(int)$object->getScopeId()
|
||||
);
|
||||
|
||||
if (is_array($oldValue)) {
|
||||
$oldValue = $this->serializer->serialize($oldValue);
|
||||
}
|
||||
|
||||
return [
|
||||
$object->getPath() => $oldValue
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Value $object
|
||||
* @return array
|
||||
*/
|
||||
public function processAfterSave($object): array
|
||||
{
|
||||
return [
|
||||
$object->getPath() => $object->getValue()
|
||||
];
|
||||
}
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
<?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\Logging\Entity\SaveHandler\Customer;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Logging\Util\Ignore\ArrayFilter;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
use Amasty\AdminActionsLog\Model\OptionSource\LogEntryTypes;
|
||||
use Magento\Customer\Api\CustomerRepositoryInterface;
|
||||
use Magento\Eav\Model\ResourceModel\Attribute\Collection;
|
||||
use Magento\Store\Model\Store;
|
||||
|
||||
class Customer extends Common
|
||||
{
|
||||
public const CATEGORY = 'customer/index/edit';
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected $dataKeysIgnoreList = [
|
||||
'assistance_allowed',
|
||||
'entity_id',
|
||||
'rp_token',
|
||||
'rp_token_created_at',
|
||||
'ignore_validation_flag',
|
||||
'password_hash',
|
||||
'failures_num',
|
||||
'dob_is_formated',
|
||||
'updated_at'
|
||||
];
|
||||
|
||||
public function __construct(
|
||||
?CustomerRepositoryInterface $customerRepository, // @deprecated
|
||||
ArrayFilter\ScalarValueFilter $scalarValueFilter,
|
||||
ArrayFilter\KeyFilter $keyFilter
|
||||
) {
|
||||
parent::__construct($scalarValueFilter, $keyFilter);
|
||||
}
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var \Magento\Customer\Model\Backend\Customer $customer */
|
||||
$customer = $metadata->getObject();
|
||||
$type = $customer->hasData(Collection::EAV_CODE_PASSWORD_HASH)
|
||||
? LogEntryTypes::TYPE_EDIT
|
||||
: LogEntryTypes::TYPE_NEW;
|
||||
|
||||
return [
|
||||
LogEntry::TYPE => $type,
|
||||
LogEntry::ITEM => $customer->getName(),
|
||||
LogEntry::CATEGORY => self::CATEGORY,
|
||||
LogEntry::CATEGORY_NAME => __('Customer'),
|
||||
LogEntry::ELEMENT_ID => (int)$customer->getId(),
|
||||
LogEntry::STORE_ID => Store::DEFAULT_STORE_ID,
|
||||
];
|
||||
}
|
||||
|
||||
public function processBeforeSave($object): array
|
||||
{
|
||||
return $this->filterObjectData((array)$object->getOrigData());
|
||||
}
|
||||
}
|
||||
+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\Logging\Entity\SaveHandler\Customer;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
use Amasty\AdminActionsLog\Model\OptionSource\LogEntryTypes;
|
||||
|
||||
class CustomerAddress extends Common
|
||||
{
|
||||
public const CATEGORY = 'customer/index/edit';
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected $dataKeysIgnoreList = [
|
||||
'id',
|
||||
'customer_id',
|
||||
'store_id',
|
||||
'attribute_set_id'
|
||||
];
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var \Magento\Customer\Model\Address $address */
|
||||
$address = $metadata->getObject();
|
||||
$type = $address->getOrigData() === null ? LogEntryTypes::TYPE_NEW : LogEntryTypes::TYPE_EDIT;
|
||||
|
||||
return [
|
||||
LogEntry::TYPE => $type,
|
||||
LogEntry::ITEM => $address->getName(),
|
||||
LogEntry::CATEGORY => self::CATEGORY,
|
||||
LogEntry::CATEGORY_NAME => __('Customer Address'),
|
||||
LogEntry::ELEMENT_ID => (int)$address->getCustomerId(),
|
||||
];
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<?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\Logging\Entity\SaveHandler\Customer;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
|
||||
class CustomerGroup extends Common
|
||||
{
|
||||
public const CATEGORY = 'customer/group/edit';
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected $dataKeysIgnoreList = [
|
||||
'tax_class_name'
|
||||
];
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var \Magento\Customer\Model\Group $group */
|
||||
$group = $metadata->getObject();
|
||||
|
||||
return [
|
||||
LogEntry::ITEM => $group->getCustomerGroupCode(),
|
||||
LogEntry::CATEGORY => self::CATEGORY,
|
||||
LogEntry::CATEGORY_NAME => __('Customer Group'),
|
||||
LogEntry::ELEMENT_ID => (int)$group->getId(),
|
||||
];
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
<?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\Logging\Entity\SaveHandler\Customer;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
|
||||
class CustomerSegment extends Common
|
||||
{
|
||||
public const CATEGORY = 'customersegment/index/edit';
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected $dataKeysIgnoreList = [
|
||||
'id',
|
||||
'segment_id',
|
||||
'form_key',
|
||||
];
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var \Magento\CustomerSegment\Model\Segment $segment */
|
||||
$segment = $metadata->getObject();
|
||||
|
||||
return [
|
||||
LogEntry::ITEM => $segment->getName(),
|
||||
LogEntry::CATEGORY => self::CATEGORY,
|
||||
LogEntry::CATEGORY_NAME => __('Customer Segment'),
|
||||
LogEntry::ELEMENT_ID => (int)$segment->getId(),
|
||||
];
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
<?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\Logging\Entity\SaveHandler;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
|
||||
class EavAttribute extends Common
|
||||
{
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected $dataKeysIgnoreList = [
|
||||
'form_key',
|
||||
];
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attribute */
|
||||
$attribute = $metadata->getObject();
|
||||
|
||||
return [
|
||||
LogEntry::ITEM => $attribute->getName(),
|
||||
LogEntry::CATEGORY => 'catalog/product_attribute/edit',
|
||||
LogEntry::CATEGORY_NAME => __('Product Attribute'),
|
||||
LogEntry::ELEMENT_ID => (int)$attribute->getId(),
|
||||
LogEntry::STORE_ID => (int)$attribute->getStoreId(),
|
||||
LogEntry::PARAMETER_NAME => 'attribute_id'
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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\Logging\Entity\SaveHandler;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
|
||||
class Flag extends Common
|
||||
{
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
$flag = $metadata->getObject();
|
||||
|
||||
return [
|
||||
LogEntry::ITEM => $flag->getFlagCode(),
|
||||
LogEntry::CATEGORY => __('Flag'),
|
||||
LogEntry::CATEGORY_NAME => __('Flag'),
|
||||
LogEntry::ELEMENT_ID => (int)$flag->getId()
|
||||
];
|
||||
}
|
||||
}
|
||||
Executable
+66
@@ -0,0 +1,66 @@
|
||||
<?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\Logging\Entity\SaveHandler\Inventory\Model;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Catalog\Product;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Logging\Util\Ignore\ArrayFilter;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
use Magento\Framework\Exception\NoSuchEntityException;
|
||||
use Magento\Inventory\Model\SourceItem as InventorySourceItem;
|
||||
|
||||
class SourceItem extends Common
|
||||
{
|
||||
public const CATEGORY = 'catalog/product/edit/source/item';
|
||||
|
||||
/**
|
||||
* @var ProductRepositoryInterface
|
||||
*/
|
||||
private $productRepository;
|
||||
|
||||
public function __construct(
|
||||
ArrayFilter\ScalarValueFilter $scalarValueFilter,
|
||||
ArrayFilter\KeyFilter $keyFilter,
|
||||
ProductRepositoryInterface $productRepository
|
||||
) {
|
||||
parent::__construct(
|
||||
$scalarValueFilter,
|
||||
$keyFilter
|
||||
);
|
||||
$this->productRepository = $productRepository;
|
||||
}
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var InventorySourceItem $sourceItem */
|
||||
$sourceItem = $metadata->getObject();
|
||||
|
||||
$logMetadata = [
|
||||
LogEntry::ITEM => $sourceItem->getSku(),
|
||||
LogEntry::CATEGORY => self::CATEGORY,
|
||||
LogEntry::CATEGORY_NAME => __('Source Item (%1)', $sourceItem->getSourceCode()),
|
||||
LogEntry::ELEMENT_ID => $sourceItem->getId()
|
||||
];
|
||||
|
||||
try {
|
||||
$product = $this->productRepository->get($sourceItem->getSku());
|
||||
|
||||
$logMetadata[LogEntry::VIEW_ELEMENT_ID] = $product->getId();
|
||||
$logMetadata[LogEntry::ITEM] = $product->getName();
|
||||
} catch (NoSuchEntityException $e) {
|
||||
null;
|
||||
}
|
||||
|
||||
return $logMetadata;
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
<?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\Logging\Entity\SaveHandler\Marketing\Communications;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
|
||||
class EmailTemplates extends Common
|
||||
{
|
||||
public const CATEGORY = 'admin/email_template/edit';
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected $dataKeysIgnoreList = [
|
||||
'template_id',
|
||||
'added_at'
|
||||
];
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var \Magento\Email\Model\BackendTemplate $emailTemplate */
|
||||
$emailTemplate = $metadata->getObject();
|
||||
|
||||
return [
|
||||
LogEntry::ITEM => $emailTemplate->getTemplateCode(),
|
||||
LogEntry::CATEGORY => self::CATEGORY,
|
||||
LogEntry::CATEGORY_NAME => __('Email Template'),
|
||||
LogEntry::ELEMENT_ID => (int)$emailTemplate->getId(),
|
||||
LogEntry::STORE_ID => (int)$emailTemplate->getStoreId()
|
||||
];
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
<?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\Logging\Entity\SaveHandler\Marketing\Communications;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
|
||||
class NewsletterTemplates extends Common
|
||||
{
|
||||
public const CATEGORY = 'newsletter/template/edit';
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected $dataKeysIgnoreList = [
|
||||
'template_id',
|
||||
'added_at'
|
||||
];
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var \Magento\Newsletter\Model\Template $newsletterTemplate */
|
||||
$newsletterTemplate = $metadata->getObject();
|
||||
|
||||
return [
|
||||
LogEntry::ITEM => $newsletterTemplate->getTemplateCode(),
|
||||
LogEntry::CATEGORY => self::CATEGORY,
|
||||
LogEntry::CATEGORY_NAME => __('Newsletter Template'),
|
||||
LogEntry::ELEMENT_ID => (int)$newsletterTemplate->getId(),
|
||||
LogEntry::STORE_ID => (int)$newsletterTemplate->getStoreId()
|
||||
];
|
||||
}
|
||||
}
|
||||
Executable
+48
@@ -0,0 +1,48 @@
|
||||
<?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\Logging\Entity\SaveHandler\Marketing\Promotions;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
|
||||
class CartPriceRule extends Common
|
||||
{
|
||||
public const CATEGORY = 'sales_rule/promo_quote/edit';
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected $dataKeysIgnoreList = [
|
||||
'_first_store_id',
|
||||
'form_key',
|
||||
];
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var \Magento\SalesRule\Model\Rule $cartPriceRule */
|
||||
$cartPriceRule = $metadata->getObject();
|
||||
|
||||
return [
|
||||
LogEntry::ITEM => $cartPriceRule->getName(),
|
||||
LogEntry::CATEGORY => self::CATEGORY,
|
||||
LogEntry::CATEGORY_NAME => __('Cart Price Rule'),
|
||||
LogEntry::ELEMENT_ID => (int)$cartPriceRule->getId(),
|
||||
];
|
||||
}
|
||||
|
||||
public function processAfterSave($object): array
|
||||
{
|
||||
$object->load($object->getId());
|
||||
|
||||
return parent::processAfterSave($object);
|
||||
}
|
||||
}
|
||||
app/code/Amasty/AdminActionsLog/Logging/Entity/SaveHandler/Marketing/Promotions/CatalogPriceRule.php
Executable
+41
@@ -0,0 +1,41 @@
|
||||
<?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\Logging\Entity\SaveHandler\Marketing\Promotions;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
|
||||
class CatalogPriceRule extends Common
|
||||
{
|
||||
public const CATEGORY = 'catalog_rule/promo_catalog/edit';
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected $dataKeysIgnoreList = [
|
||||
'_first_store_id',
|
||||
'form_key',
|
||||
];
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var \Magento\CatalogRule\Model\Rule $catalogPriceRule */
|
||||
$catalogPriceRule = $metadata->getObject();
|
||||
|
||||
return [
|
||||
LogEntry::ITEM => $catalogPriceRule->getName(),
|
||||
LogEntry::CATEGORY => self::CATEGORY,
|
||||
LogEntry::CATEGORY_NAME => __('Catalog Price Rule'),
|
||||
LogEntry::ELEMENT_ID => (int)$catalogPriceRule->getId()
|
||||
];
|
||||
}
|
||||
}
|
||||
app/code/Amasty/AdminActionsLog/Logging/Entity/SaveHandler/Marketing/Promotions/GiftCardAccounts.php
Executable
+42
@@ -0,0 +1,42 @@
|
||||
<?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\Logging\Entity\SaveHandler\Marketing\Promotions;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
|
||||
class GiftCardAccounts extends Common
|
||||
{
|
||||
public const CATEGORY = 'admin/giftcardaccount/edit';
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected $dataKeysIgnoreList = [
|
||||
'_first_store_id',
|
||||
'form_key',
|
||||
];
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var \Magento\GiftCardAccount\Model\Giftcardaccount $giftCardAccount */
|
||||
$giftCardAccount = $metadata->getObject();
|
||||
|
||||
return [
|
||||
LogEntry::ITEM => __('Gift Card Account #%1', $giftCardAccount->getId()),
|
||||
LogEntry::CATEGORY => self::CATEGORY,
|
||||
LogEntry::CATEGORY_NAME => __('Gift Card Account'),
|
||||
LogEntry::ELEMENT_ID => (int)$giftCardAccount->getId(),
|
||||
LogEntry::STORE_ID => (int)$giftCardAccount->getStoreId()
|
||||
];
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
<?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\Logging\Entity\SaveHandler\Marketing\Promotions;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
|
||||
class RelatedProductsRule extends Common
|
||||
{
|
||||
public const CATEGORY = 'admin/targetrule/edit';
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected $dataKeysIgnoreList = [
|
||||
'_first_store_id',
|
||||
'form_key',
|
||||
];
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var \Magento\TargetRule\Model\Rule $relatedProductsRule */
|
||||
$relatedProductsRule = $metadata->getObject();
|
||||
|
||||
return [
|
||||
LogEntry::ITEM => $relatedProductsRule->getName(),
|
||||
LogEntry::CATEGORY => self::CATEGORY,
|
||||
LogEntry::CATEGORY_NAME => __('Related Products Rule'),
|
||||
LogEntry::ELEMENT_ID => (int)$relatedProductsRule->getId(),
|
||||
LogEntry::STORE_ID => (int)$relatedProductsRule->getStoreId()
|
||||
];
|
||||
}
|
||||
}
|
||||
+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\Logging\Entity\SaveHandler\Marketing\Seo;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
use Magento\Store\Model\Store;
|
||||
|
||||
class UrlRewrite extends Common
|
||||
{
|
||||
public const CATEGORY = 'admin/url_rewrite/edit';
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected $dataKeysIgnoreList = [
|
||||
'_first_store_id',
|
||||
'form_key',
|
||||
];
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var \Magento\UrlRewrite\Model\UrlRewrite $urlRewrite */
|
||||
$urlRewrite = $metadata->getObject();
|
||||
|
||||
return [
|
||||
LogEntry::ITEM => $urlRewrite->getRequestPath(),
|
||||
LogEntry::CATEGORY => self::CATEGORY,
|
||||
LogEntry::CATEGORY_NAME => __('URL Rewrite'),
|
||||
LogEntry::ELEMENT_ID => (int)$urlRewrite->getId(),
|
||||
LogEntry::STORE_ID => Store::DEFAULT_STORE_ID
|
||||
];
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
<?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\Logging\Entity\SaveHandler\Sales;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
use Amasty\AdminActionsLog\Model\OptionSource\LogEntryTypes;
|
||||
|
||||
class Creditmemo extends Common
|
||||
{
|
||||
public const CATEGORY = 'sales/order_creditmemo/view';
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var \Magento\Sales\Model\Order\Creditmemo $creditMemo */
|
||||
$creditMemo = $metadata->getObject();
|
||||
$type = $creditMemo->getOrigData() === null ? LogEntryTypes::TYPE_NEW : LogEntryTypes::TYPE_EDIT;
|
||||
|
||||
return [
|
||||
LogEntry::TYPE => $type,
|
||||
LogEntry::ITEM => __('Credit Memo for Order #%1', $creditMemo->getOrder()->getRealOrderId()),
|
||||
LogEntry::CATEGORY => self::CATEGORY,
|
||||
LogEntry::CATEGORY_NAME => __('Credit Memo'),
|
||||
LogEntry::ELEMENT_ID => (int)$creditMemo->getId(),
|
||||
LogEntry::PARAMETER_NAME => 'creditmemo_id'
|
||||
];
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
<?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\Logging\Entity\SaveHandler\Sales;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
use Amasty\AdminActionsLog\Model\OptionSource\LogEntryTypes;
|
||||
|
||||
class Invoice extends Common
|
||||
{
|
||||
public const CATEGORY = 'sales/order_invoice/view';
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var \Magento\Sales\Model\Order\Invoice $invoice */
|
||||
$invoice = $metadata->getObject();
|
||||
$type = $invoice->getOrigData() === null ? LogEntryTypes::TYPE_NEW : LogEntryTypes::TYPE_EDIT;
|
||||
|
||||
return [
|
||||
LogEntry::TYPE => $type,
|
||||
LogEntry::ITEM => __('Invoice for Order #%1', $invoice->getOrder()->getRealOrderId()),
|
||||
LogEntry::CATEGORY => self::CATEGORY,
|
||||
LogEntry::CATEGORY_NAME => __('Invoice'),
|
||||
LogEntry::ELEMENT_ID => (int)$invoice->getId(),
|
||||
LogEntry::PARAMETER_NAME => 'invoice_id'
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?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\Logging\Entity\SaveHandler\Sales;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
use Amasty\AdminActionsLog\Model\OptionSource\LogEntryTypes;
|
||||
|
||||
class Order extends Common
|
||||
{
|
||||
public const CATEGORY = 'sales/order/view';
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var \Magento\Sales\Model\Order $order */
|
||||
$order = $metadata->getObject();
|
||||
$type = $order->getOrigData() === null ? LogEntryTypes::TYPE_NEW : LogEntryTypes::TYPE_EDIT;
|
||||
|
||||
return [
|
||||
LogEntry::TYPE => $type,
|
||||
LogEntry::ITEM => __('Order #%1', $order->getRealOrderId()),
|
||||
LogEntry::CATEGORY => self::CATEGORY,
|
||||
LogEntry::CATEGORY_NAME => __('Order'),
|
||||
LogEntry::ELEMENT_ID => (int)$order->getId(),
|
||||
LogEntry::PARAMETER_NAME => 'order_id'
|
||||
];
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
<?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\Logging\Entity\SaveHandler\Sales;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
use Amasty\AdminActionsLog\Model\OptionSource\LogEntryTypes;
|
||||
|
||||
class OrderAddress extends Common
|
||||
{
|
||||
public const CATEGORY = 'sales/order/address';
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected $dataKeysIgnoreList = [
|
||||
'form_key',
|
||||
'region_code'
|
||||
];
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var \Magento\Sales\Model\Order\Address $address */
|
||||
$address = $metadata->getObject();
|
||||
$type = $address->getOrigData() === null ? LogEntryTypes::TYPE_NEW : LogEntryTypes::TYPE_EDIT;
|
||||
|
||||
return [
|
||||
LogEntry::TYPE => $type,
|
||||
LogEntry::ITEM => __(
|
||||
'%1 Address for Order #%2',
|
||||
ucfirst($address->getAddressType()),
|
||||
$address->getOrder()->getRealOrderId()
|
||||
),
|
||||
LogEntry::CATEGORY => self::CATEGORY,
|
||||
LogEntry::CATEGORY_NAME => __('Order Address'),
|
||||
LogEntry::ELEMENT_ID => (int)$address->getId(),
|
||||
LogEntry::PARAMETER_NAME => 'address_id'
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?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\Logging\Entity\SaveHandler\Sales;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
|
||||
class Rma extends Common
|
||||
{
|
||||
public const CATEGORY = 'admin/rma/edit';
|
||||
|
||||
/**
|
||||
* @param MetadataInterface $metadata
|
||||
* @return array
|
||||
*/
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var \Magento\Rma\Model\Rma $rma */
|
||||
$rma = $metadata->getObject();
|
||||
|
||||
return [
|
||||
LogEntry::ITEM => __('Return Request #%1', $rma->getId()),
|
||||
LogEntry::CATEGORY => self::CATEGORY,
|
||||
LogEntry::CATEGORY_NAME => __('RMA'),
|
||||
LogEntry::ELEMENT_ID => (int)$rma->getId()
|
||||
];
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
<?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\Logging\Entity\SaveHandler\Sales;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
use Amasty\AdminActionsLog\Model\OptionSource\LogEntryTypes;
|
||||
|
||||
class Shipment extends Common
|
||||
{
|
||||
public const CATEGORY = 'sales/shipment/view';
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var \Magento\Sales\Model\Order\Shipment $shipment */
|
||||
$shipment = $metadata->getObject();
|
||||
$type = $shipment->getOrigData() === null ? LogEntryTypes::TYPE_NEW : LogEntryTypes::TYPE_EDIT;
|
||||
|
||||
return [
|
||||
LogEntry::TYPE => $type,
|
||||
LogEntry::ITEM => __('Shipment for Order #%1', $shipment->getOrder()->getRealOrderId()),
|
||||
LogEntry::CATEGORY => self::CATEGORY,
|
||||
LogEntry::CATEGORY_NAME => __('Shipment'),
|
||||
LogEntry::ELEMENT_ID => (int)$shipment->getId(),
|
||||
LogEntry::PARAMETER_NAME => 'shipment_id'
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user