Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ProductFrontendActionSection.php
Go to the documentation of this file.
1 <?php
7 
12 use Psr\Log\LoggerInterface;
13 
18 {
24  private $typeId;
25 
29  private $synchronizer;
30 
34  private $logger;
35 
39  private $appConfig;
40 
47  public function __construct(
48  Synchronizer $synchronizer,
49  $typeId,
50  LoggerInterface $logger,
51  Config $appConfig
52  ) {
53  $this->typeId = $typeId;
54  $this->synchronizer = $synchronizer;
55  $this->logger = $logger;
56  $this->appConfig = $appConfig;
57  }
58 
64  public function getSectionData()
65  {
66  if (!(bool) $this->appConfig->getValue(Synchronizer::ALLOW_SYNC_WITH_BACKEND_PATH)) {
67  return [
68  'count' => 0,
69  'items' => [],
70  ];
71  }
72 
73  $actions = $this->synchronizer->getActionsByType($this->typeId);
74  $items = [];
75 
77  foreach ($actions as $action) {
78  $items[$action->getProductId()] = [
79  'added_at' => $action->getAddedAt(),
80  'product_id' => $action->getProductId(),
81  ];
82  }
83 
84  return [
85  'count' => count($items),
86  'items' => $items,
87  ];
88  }
89 }
$logger
__construct(Synchronizer $synchronizer, $typeId, LoggerInterface $logger, Config $appConfig)
$items