Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ProductsRenderInfoSection.php
Go to the documentation of this file.
1 <?php
7 
18 
23 {
27  private $storeManager;
28 
32  private $hydrator;
33 
37  private $searchCriteriaBuilder;
38 
42  private $filterBuilder;
43 
47  private $productRenderList;
48 
52  private $actionsSynchronizer;
53 
63  public function __construct(
64  StoreManager $storeManager,
65  SearchCriteriaBuilder $searchCriteriaBuilder,
66  FilterBuilder $filterBuilder,
67  ProductRenderList $productRenderList,
68  Synchronizer $actionsSynchronizer,
69  Hydrator $hydrator
70  ) {
71  $this->storeManager = $storeManager;
72  $this->hydrator = $hydrator;
73  $this->searchCriteriaBuilder = $searchCriteriaBuilder;
74  $this->filterBuilder = $filterBuilder;
75  $this->productRenderList = $productRenderList;
76  $this->actionsSynchronizer = $actionsSynchronizer;
77  }
78 
84  private function getProductIds()
85  {
86  $productIds = [];
88  $actionCollection = $this->actionsSynchronizer->getAllActions();
89 
91  foreach ($actionCollection as $action) {
92  $productIds[] = $action->getProductId();
93  }
94 
95  return $productIds;
96  }
97 
101  public function getSectionData()
102  {
103  $sectionData = [];
104  $store = $this->storeManager->getStore();
105  $filter = $this->filterBuilder
106  ->setField('entity_id')
107  ->setValue($this->getProductIds())
108  ->setConditionType('in')
109  ->create();
110  $searchCriteria = $this->searchCriteriaBuilder
111  ->addFilters([$filter])
112  ->create();
113  $renderSearchResults = $this->productRenderList->getList(
115  $store->getId(),
116  $store->getCurrentCurrencyCode()
117  );
118 
120  foreach ($renderSearchResults->getItems() as $item) {
121  $sectionData[$item->getId()] = $this->hydrator->extract($item);
122  }
123 
124  return $sectionData;
125  }
126 }
$storeManager
__construct(StoreManager $storeManager, SearchCriteriaBuilder $searchCriteriaBuilder, FilterBuilder $filterBuilder, ProductRenderList $productRenderList, Synchronizer $actionsSynchronizer, Hydrator $hydrator)
$searchCriteria
$searchCriteriaBuilder