From c5c80cc06b718f26fa5a5a9ea0c29913504cf6bc Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 20 Oct 2016 13:20:42 +0300 Subject: [PATCH] big commti --- common/modules/product/CatalogUrlManager.php | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------- frontend/views/event/_product_item.php | 8 ++++---- 2 files changed, 61 insertions(+), 13 deletions(-) diff --git a/common/modules/product/CatalogUrlManager.php b/common/modules/product/CatalogUrlManager.php index 57c28c8..a396d97 100755 --- a/common/modules/product/CatalogUrlManager.php +++ b/common/modules/product/CatalogUrlManager.php @@ -35,9 +35,12 @@ class CatalogUrlManager implements UrlRuleInterface { preg_match($pattern,$paths[0], $match ); if(!empty($match)){ $old_item_name = explode('-',$paths[0] ); + array_pop($old_item_name); + $count = count($old_item_name)-1; - if(isset($old_item_name[5]) && isset($old_item_name[5]) == 'dis' ){ - $sku = $old_item_name[2].'/'.$old_item_name[3].'/'.$old_item_name[4].'_'.$old_item_name[5]; + if(isset($old_item_name[$count]) && $old_item_name[$count] == 'dis' ){ + + $sku = $old_item_name[$count-3].'/'.$old_item_name[$count-2].'/'.$old_item_name[$count-1].'_'.$old_item_name[$count]; $product_variant = ProductVariant::find()->where(['sku'=>$sku])->one(); if($product_variant instanceof ProductVariant){ @@ -49,8 +52,9 @@ class CatalogUrlManager implements UrlRuleInterface { } - if(isset($old_item_name[2]) && isset($old_item_name[3]) && isset($old_item_name[4])&& isset($old_item_name[5])){ - $sku = $old_item_name[2].'/'.$old_item_name[3].'/'.$old_item_name[4].'/'.$old_item_name[5]; + if(isset($old_item_name[$count-3]) && isset($old_item_name[$count-2]) && isset($old_item_name[$count-1]) && isset($old_item_name[$count])){ + + $sku = $old_item_name[$count-3].'/'.$old_item_name[$count-2].'/'.$old_item_name[$count-1].'/'.$old_item_name[$count]; $product_variant = ProductVariant::find()->where(['sku'=>$sku])->one(); if($product_variant instanceof ProductVariant){ @@ -61,11 +65,53 @@ class CatalogUrlManager implements UrlRuleInterface { } } - if(isset($old_item_name[2]) && isset($old_item_name[3]) && isset($old_item_name[4])){ - $sku = $old_item_name[2].'/'.$old_item_name[3].'/'.$old_item_name[4]; + if(isset($old_item_name[$count-2]) && isset($old_item_name[$count-1]) && isset($old_item_name[$count])){ + $sku = $old_item_name[$count-2].'/'.$old_item_name[$count-1].'/'.$old_item_name[$count]; + $product_variant = ProductVariant::find()->where(['sku'=>$sku])->one(); + + if($product_variant instanceof ProductVariant){ + + $link = 'product'.'/'. $product_variant->product->alias; + header("Status: 301"); + header("Location: http://www.test-22.artweb.com.ua/".$link); + die(); + } + $sku = $old_item_name[$count-2].'/'.$old_item_name[$count-1].' '.$old_item_name[$count]; + $product_variant = ProductVariant::find()->where(['sku'=>$sku])->one(); + + if($product_variant instanceof ProductVariant){ + $link = 'product'.'/'. $product_variant->product->alias; + header("Status: 301"); + header("Location: http://www.test-22.artweb.com.ua/".$link); + die(); + } + + $sku = $old_item_name[$count-2].'/'.$old_item_name[$count-1].'-'.$old_item_name[$count]; + $product_variant = ProductVariant::find()->where(['sku'=>$sku])->one(); + + if($product_variant instanceof ProductVariant){ + $link = 'product'.'/'. $product_variant->product->alias; + header("Status: 301"); + header("Location: http://www.test-22.artweb.com.ua/".$link); + die(); + } + + $sku = $old_item_name[$count-2].'/'.$old_item_name[$count-1].'_'.$old_item_name[$count]; $product_variant = ProductVariant::find()->where(['sku'=>$sku])->one(); if($product_variant instanceof ProductVariant){ + $link = 'product'.'/'. $product_variant->product->alias; + header("Status: 301"); + header("Location: http://www.test-22.artweb.com.ua/".$link); + die(); + } + + } + + if(isset($old_item_name[$count-1]) && isset($old_item_name[$count])){ + $sku = $old_item_name[$count-1].'/'.$old_item_name[$count]; + $product_variant = ProductVariant::find()->where(['sku'=>$sku])->one(); + if($product_variant instanceof ProductVariant){ $link = 'product'.'/'. $product_variant->product->alias; header("Status: 301"); @@ -74,8 +120,8 @@ class CatalogUrlManager implements UrlRuleInterface { } } - if(isset($old_item_name[2]) && isset($old_item_name[3])){ - $sku = $old_item_name[2].'/'.$old_item_name[3]; + if(isset($old_item_name[$count])){ + $sku = $old_item_name[$count]; $product_variant = ProductVariant::find()->where(['sku'=>$sku])->one(); if($product_variant instanceof ProductVariant){ @@ -88,7 +134,9 @@ class CatalogUrlManager implements UrlRuleInterface { } } - + /** + * end linija-svitla.ua only + */ diff --git a/frontend/views/event/_product_item.php b/frontend/views/event/_product_item.php index c0a99b4..73ce57e 100755 --- a/frontend/views/event/_product_item.php +++ b/frontend/views/event/_product_item.php @@ -28,7 +28,7 @@ $category = $model->category; } ?> - enabledVariants[ 0 ]->imageUrl, 'list', [ + variant->imageUrl, 'list', [ 'alt' => $model->category->name . ' ' . $model->fullname, 'title' => $model->category->name . ' ' . $model->fullname, 'class' => 'selected' @@ -92,10 +92,10 @@ $category = $model->category; // есть скидка echo '

'; if($model->enabledVariants[ 0 ]->price_old != 0 && $model->enabledVariants[ 0 ]->price_old != $model->enabledVariants[ 0 ]->price) { - echo '' . $model->enabledVariants[0]->price_old . ' грн. '; - echo $model->enabledVariants[0]->price . ' грн.

'; + echo '' . $model->variant->price_old . ' грн. '; + echo $model->variant->price . ' грн.

'; } else { - echo ''.$model->enabledVariants[0]->price . ' грн.

'; + echo ''.$model->variant->price . ' грн.

'; } echo ''; echo ''; -- libgit2 0.21.4