| @@ 213-243 (lines=31) @@ | ||
| 210 | /** |
|
| 211 | * @param ViewEvent $event |
|
| 212 | */ |
|
| 213 | static public function handleProductShow(ViewEvent $event) |
|
| 214 | { |
|
| 215 | if ('shop/product/show' !== trim(\Yii::$app->requestedRoute, '/')) { |
|
| 216 | return ; |
|
| 217 | } |
|
| 218 | ||
| 219 | /** @var Product $model */ |
|
| 220 | $model = isset($event->params['model']) ? $event->params['model'] : null; |
|
| 221 | if (false === $model instanceof Product) { |
|
| 222 | return ; |
|
| 223 | } |
|
| 224 | ||
| 225 | /** @var Currency $currency */ |
|
| 226 | $currency = static::$currency; |
|
| 227 | ||
| 228 | $ga = [ |
|
| 229 | 'action' => 'detail', |
|
| 230 | 'currency' => $currency->iso_code, |
|
| 231 | 'products' => [ |
|
| 232 | 'id' => $model->id, |
|
| 233 | 'name' => $model->name, |
|
| 234 | 'category' => self::getCategories($model), |
|
| 235 | 'price' => CurrencyHelper::convertCurrencies($model->price, $model->currency, $currency), |
|
| 236 | 'quantity' => null === $model->measure ? 1 : $model->measure->nominal, |
|
| 237 | ] |
|
| 238 | ]; |
|
| 239 | ||
| 240 | $js = 'window.DotPlantParams = window.DotPlantParams || {};'; |
|
| 241 | $js .= 'window.DotPlantParams.ecGoogle = ' . Json::encode($ga) . ';'; |
|
| 242 | \Yii::$app->getView()->registerJs($js, View::POS_BEGIN); |
|
| 243 | } |
|
| 244 | ||
| 245 | /** |
|
| 246 | * |
|
| @@ 212-244 (lines=33) @@ | ||
| 209 | /** |
|
| 210 | * @param ViewEvent $event |
|
| 211 | */ |
|
| 212 | static public function handleProductShow(ViewEvent $event) |
|
| 213 | { |
|
| 214 | if ('shop/product/show' !== trim(\Yii::$app->requestedRoute, '/')) { |
|
| 215 | return ; |
|
| 216 | } |
|
| 217 | ||
| 218 | /** @var Product $model */ |
|
| 219 | $model = isset($event->params['model']) ? $event->params['model'] : null; |
|
| 220 | if (false === $model instanceof Product) { |
|
| 221 | return ; |
|
| 222 | } |
|
| 223 | ||
| 224 | /** @var Currency $currency */ |
|
| 225 | $currency = static::$currency; |
|
| 226 | ||
| 227 | $ya = [ |
|
| 228 | 'action' => 'detail', |
|
| 229 | 'currency' => $currency->iso_code, |
|
| 230 | 'products' => [ |
|
| 231 | [ |
|
| 232 | 'id' => $model->id, |
|
| 233 | 'name' => $model->name, |
|
| 234 | 'category' => self::getCategories($model), |
|
| 235 | 'price' => CurrencyHelper::convertCurrencies($model->price, $model->currency, $currency), |
|
| 236 | 'quantity' => null === $model->measure ? 1 : $model->measure->nominal, |
|
| 237 | ] |
|
| 238 | ] |
|
| 239 | ]; |
|
| 240 | ||
| 241 | $js = 'window.DotPlantParams = window.DotPlantParams || {};'; |
|
| 242 | $js .= 'window.DotPlantParams.ecYandex = ' . Json::encode($ya) . ';'; |
|
| 243 | \Yii::$app->getView()->registerJs($js, View::POS_BEGIN); |
|
| 244 | } |
|
| 245 | ||
| 246 | /** |
|
| 247 | * |
|