Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 deletions src/Model/Variant/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,9 @@ protected function getIsReturnSingleChild($includeFilters = false) {
protected function getChildCollectionMapAndList(): array {
$childCollectionMap = [];
$childProductsList = [];

$parentIds = array_map(function ($product) {
return $product->getId();
$linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField();
$parentIds = array_map(function ($product) use($linkField) {
return $product->getData($linkField);
}, $this->parentProducts);

$conn = $this->connection->getConnection();
Expand Down Expand Up @@ -336,6 +336,7 @@ protected function fetch($info) : array {
$childCollectionMap
] = $this->getChildCollectionMapAndList();

$linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField();
$collection = $this->collectionFactory->create();
$isReturnSingleChild = $this->getIsReturnSingleChild(true);
$searchCriteria = $this->getSearchCriteria($childProductsList, $isReturnSingleChild);
Expand Down Expand Up @@ -364,11 +365,11 @@ protected function fetch($info) : array {

if ($isReturnSingleChild) {
foreach ($this->parentProducts as $parentProduct) {
$parentId = $parentProduct->getId();
$parentId = $parentProduct->getData($linkField);
$childIds = $childCollectionMap[$parentId];

foreach ($products as $childProduct) {
if (in_array($childProduct->getId(), $childIds, true)) {
if (in_array($childProduct->getData($linkField), $childIds, true)) {
$productsToProcess[] = $childProduct;
break;
}
Expand All @@ -385,10 +386,10 @@ protected function fetch($info) : array {
['isSingleProduct' => CriteriaCheck::isSingleProductFilter($this->searchCriteria)]
);


foreach ($this->parentProducts as $product) {
$parentId = $product->getId();
$parentId = $product->getData($linkField);
$childIds = $childCollectionMap[$parentId];

$this->childrenMap[$parentId] = [];

foreach ($childIds as $childId) {
Expand Down Expand Up @@ -420,6 +421,10 @@ protected function fetchPlp($info) : array {
return $this->childrenMap;
}



$linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField();

[
$childProductsList,
$childCollectionMap
Expand Down Expand Up @@ -467,7 +472,7 @@ protected function fetchPlp($info) : array {
continue;
}

$productId = $product->getId();
$productId = $product->getData($linkField);
$productIds[] = $productId;

// Create storage for future attributes
Expand All @@ -492,16 +497,16 @@ protected function fetchPlp($info) : array {
// Set stock status
$stockStatusCallback($product);


$productsData[$product->getId()] = $product->getData() + [
'model' => $product,
's_attributes' => $productAttributes[$productId]
];
'model' => $product,
's_attributes' => $productAttributes[$productId]
];
}

foreach ($this->parentProducts as $product) {
$parentId = $product->getId();
$parentId = $product->getData($linkField);
$childIds = $childCollectionMap[$parentId];

$this->childrenMap[$parentId] = [];

foreach ($childIds as $childId) {
Expand Down