26 private $dataProvider;
36 private $staticFields;
46 private $dynamicFields;
56 private $allowedVisibility;
71 private $lastProductId = 0;
76 private $products = [];
81 private $current =
null;
86 private $isValid =
true;
96 private $productAttributes = [];
101 private $productRelations = [];
123 array $dynamicFields,
125 array $allowedVisibility,
129 $this->dataProvider = $dataProvider;
130 $this->storeId = $storeId;
131 $this->staticFields = $staticFields;
132 $this->productIds = $productIds;
133 $this->dynamicFields = $dynamicFields;
134 $this->visibility = $visibility;
135 $this->allowedVisibility = $allowedVisibility;
137 $this->statusIds = $statusIds;
148 return $this->current;
159 \next($this->products);
160 if (\
key($this->products) ===
null) {
162 $this->products = $this->dataProvider->getSearchableProducts(
169 if (!count($this->products)) {
170 $this->isValid =
false;
174 $productAttributes = [];
175 $this->productRelations = [];
179 $productChildren = $this->dataProvider->getProductChildIds(
183 $this->productRelations[
$productData[
'entity_id']] = $productChildren;
184 if ($productChildren) {
185 foreach ($productChildren as $productChildId) {
186 $productAttributes[$productChildId] = $productChildId;
190 \reset($this->products);
192 $this->productAttributes = $this->dataProvider->getProductAttributes(
201 if (!isset($this->productAttributes[
$productData[
'entity_id']])) {
206 $productAttr = $this->productAttributes[
$productData[
'entity_id']];
207 if (!isset($productAttr[$this->visibility->getId()])
208 || !in_array($productAttr[$this->visibility->getId()], $this->allowedVisibility)
213 if (!isset($productAttr[$this->status->getId()])
214 || !in_array($productAttr[$this->status->getId()], $this->statusIds)
220 $productIndex = [
$productData[
'entity_id'] => $productAttr];
222 $hasChildren =
false;
223 $productChildren = $this->productRelations[
$productData[
'entity_id']];
224 if ($productChildren) {
225 foreach ($productChildren as $productChildId) {
226 if (isset($this->productAttributes[$productChildId])) {
227 $productChildAttr = $this->productAttributes[$productChildId];
228 if (!isset($productChildAttr[$this->status->getId()])
229 || !in_array($productChildAttr[$this->status->getId()], $this->statusIds)
235 $productIndex[$productChildId] = $productChildAttr;
239 if ($productChildren !==
null && !$hasChildren) {
244 $index = $this->dataProvider->prepareProductIndex($productIndex,
$productData, $this->storeId);
247 $this->
key = $productData[
'entity_id'];
269 return $this->isValid;
280 $this->lastProductId = 0;
283 unset($this->products);
284 $this->products = [];
__construct(DataProvider $dataProvider, $storeId, array $staticFields, $productIds, array $dynamicFields, \Magento\Eav\Model\Entity\Attribute $visibility, array $allowedVisibility, \Magento\Eav\Model\Entity\Attribute $status, array $statusIds)