Skip to content

Commit 361043f

Browse files
committed
MAGE-1112: make price attribute optional on product records
1 parent f900207 commit 361043f

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

Service/Product/RecordBuilder.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,11 @@ public function buildRecord(DataObject $entity): array
123123
}
124124
$subProducts = $this->getSubProducts($product);
125125
$customData = $this->addAdditionalAttributes($customData, $additionalAttributes, $product, $subProducts);
126-
$customData = $this->priceManager->addPriceDataByProductType($customData, $product, $subProducts);
126+
127+
if ($this->isPriceIndexingEnabled($additionalAttributes)) {
128+
$customData = $this->priceManager->addPriceDataByProductType($customData, $product, $subProducts);
129+
}
130+
127131
$transport = new DataObject($customData);
128132
$this->eventManager->dispatch(
129133
'algolia_subproducts_index',
@@ -195,6 +199,15 @@ public function isAttributeEnabled($additionalAttributes, $attributeName): bool
195199
return false;
196200
}
197201

202+
/**
203+
* @param array $additionalAttributes
204+
* @return bool
205+
*/
206+
protected function isPriceIndexingEnabled(array $additionalAttributes): bool
207+
{
208+
return $this->isAttributeEnabled($additionalAttributes, 'price');
209+
}
210+
198211
/**
199212
* @param array $algoliaData Data for product object to be serialized to Algolia index
200213
* @param Product $product
@@ -816,3 +829,4 @@ public function productIsInStock($product, $storeId): bool
816829
return $product->isSaleable() && $stockItem->getIsInStock();
817830
}
818831
}
832+

0 commit comments

Comments
 (0)