Smile\ElasticsuiteCatalog\Model\ResourceModel\Product\Indexer\Fulltext\Datasource\PriceData::loadPriceData PHP Метод

loadPriceData() публичный Метод

Load prices data for a list of product ids and a given store.
public loadPriceData ( integer $storeId, array $productIds ) : array
$storeId integer Store id.
$productIds array Product ids list.
Результат array
    public function loadPriceData($storeId, $productIds)
    {
        $websiteId = $this->getStore($storeId)->getWebsiteId();
        $select = $this->getConnection()->select()->from(['p' => $this->getTable('catalog_product_index_price')])->where('p.website_id = ?', $websiteId)->where('p.entity_id IN(?)', $productIds);
        return $this->getConnection()->fetchAll($select);
    }

Usage Example

Пример #1
0
 /**
  * Add price data to the index data.
  *
  * {@inheritdoc}
  */
 public function addData($storeId, array $indexData)
 {
     $priceData = $this->resourceModel->loadPriceData($storeId, array_keys($indexData));
     foreach ($priceData as $priceDataRow) {
         $productId = (int) $priceDataRow['entity_id'];
         $isOriginalPriceReliable = $this->isOriginalPriceReliable($indexData[$productId]['type_id']);
         $originalPrice = $priceDataRow['min_price'];
         $finalPrice = $priceDataRow['min_price'];
         if ($isOriginalPriceReliable) {
             if ($priceDataRow['price']) {
                 $originalPrice = $priceDataRow['price'];
             }
             if ($priceDataRow['final_price']) {
                 $finalPrice = $priceDataRow['final_price'];
             }
         }
         $indexData[$productId]['price'][] = ['price' => $finalPrice, 'original_price' => $originalPrice, 'is_discount' => $finalPrice < $originalPrice, 'customer_group_id' => $priceDataRow['customer_group_id']];
     }
     return $indexData;
 }
PriceData