return $writeOffProductsWithoutRetailPriceSetCounter;
}
- public static function getPriceDynamic($productId, $writeOffDate)
+ public static function getPriceDynamic($productId, $writeOffDate, $regionId = 52)
{
$query = PricesDynamic::find()
->select(['price'])
- ->andWhere(['product_id' => $productId])
+ ->where(['region_id' => $regionId, 'product_id' => $productId])
->andWhere(['<=', 'date_from', $writeOffDate])
- ->andWhere(['>=', 'date_to', $writeOffDate])
- ->andWhere(['<=', 'date_from', $writeOffDate])
- ->andWhere(['>=', 'date_to', $writeOffDate])
+ ->andWhere(['or', 'date_to IS NULL', ['>=', 'date_to', $writeOffDate]])
;
$pricesDynamic = $query->scalar();