/** * Update price and max_price for configurable product * @param ShopProduct $model */ public function updatePrices(ShopProduct $model) { // Get min and max prices $query = Yii::app()->db->createCommand()->select('MIN(t.price) as min_price, MAX(t.price) as max_price')->from('{{shop_product}} t')->where(array('in', 't.id', $model->getConfigurations(true)))->queryRow(); // Update Yii::app()->db->createCommand()->update('{{shop_product}}', array('price' => $query['min_price'], 'max_price' => $query['max_price']), 'id=:id', array(':id' => $model->id)); }