![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/app/code/Cnc/AdminHistory/Block/Adminhtml/Catalog/Product/Tab/ |
<?php /** * Copyright (c) 2020 Kaliop Digital Commerce (https://digitalcommerce.kaliop.com) All Rights Reserved. * https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * Cnc * Radosław Stępień <[email protected]> <[email protected]> */ declare(strict_types=1); namespace Cnc\AdminHistory\Block\Adminhtml\Catalog\Product\Tab; use Exception; use Magento\Backend\Block\Template\Context; use Magento\Backend\Block\Widget\Grid\Extended; use Magento\Backend\Helper\Data; use Magento\Framework\Registry; use Cnc\AdminHistory\Model\ResourceModel\Product\Collection; use Cnc\AdminHistory\Model\ResourceModel\Product\CollectionFactory; /** * Class History * Logs history for specified product */ class History extends Extended { /** * @var Registry */ protected $coreRegistry; /** * @var CollectionFactory */ protected $collection; /** * History constructor. * @param Context $context * @param Data $backendHelper * @param Registry $coreRegistry * @param CollectionFactory $collection * @param array $data */ public function __construct( Context $context, Data $backendHelper, Registry $coreRegistry, CollectionFactory $collection, array $data = [] ) { parent::__construct($context, $backendHelper, $data); $this->coreRegistry = $coreRegistry; $this->collection = $collection; } /** * @return array|null */ public function getProduct() { return $this->coreRegistry->registry('product'); } /** * @return History */ protected function _prepareCollection() { $collection = $this->collection->create() ->addFieldToFilter('product_id', ['in' => $this->getProduct()->getId()]) ->setOrder('updated_at', 'DESC'); $this->setCollection($collection); return parent::_prepareCollection(); } /** * @return Extended * @throws Exception */ protected function _prepareColumns() { $this->addColumn( 'entity_id', [ 'header' => __('ID'), 'sortable' => true, 'index' => 'entity_id', 'header_css_class' => 'col-id', 'column_css_class' => 'col-id' ] ); $this->addColumn('attribute_code', ['header' => __('Attribute code'), 'index' => 'attribute_code']); $this->addColumn('old_value', ['header' => __('Old value'), 'index' => 'old_value']); $this->addColumn('new_value', ['header' => __('New Value'), 'index' => 'new_value']); $this->addColumn('user', ['header' => __('Admin user'), 'index' => 'user']); $this->addColumn('updated_at', ['header' => __('Updated at'), 'index' => 'updated_at']); return parent::_prepareColumns(); } }