Commit c5c80cc06b718f26fa5a5a9ea0c29913504cf6bc
1 parent
b4b39c8e
big commti
Showing
2 changed files
with
61 additions
and
13 deletions
Show diff stats
common/modules/product/CatalogUrlManager.php
@@ -35,9 +35,12 @@ class CatalogUrlManager implements UrlRuleInterface { | @@ -35,9 +35,12 @@ class CatalogUrlManager implements UrlRuleInterface { | ||
35 | preg_match($pattern,$paths[0], $match ); | 35 | preg_match($pattern,$paths[0], $match ); |
36 | if(!empty($match)){ | 36 | if(!empty($match)){ |
37 | $old_item_name = explode('-',$paths[0] ); | 37 | $old_item_name = explode('-',$paths[0] ); |
38 | + array_pop($old_item_name); | ||
39 | + $count = count($old_item_name)-1; | ||
38 | 40 | ||
39 | - if(isset($old_item_name[5]) && isset($old_item_name[5]) == 'dis' ){ | ||
40 | - $sku = $old_item_name[2].'/'.$old_item_name[3].'/'.$old_item_name[4].'_'.$old_item_name[5]; | 41 | + if(isset($old_item_name[$count]) && $old_item_name[$count] == 'dis' ){ |
42 | + | ||
43 | + $sku = $old_item_name[$count-3].'/'.$old_item_name[$count-2].'/'.$old_item_name[$count-1].'_'.$old_item_name[$count]; | ||
41 | $product_variant = ProductVariant::find()->where(['sku'=>$sku])->one(); | 44 | $product_variant = ProductVariant::find()->where(['sku'=>$sku])->one(); |
42 | if($product_variant instanceof ProductVariant){ | 45 | if($product_variant instanceof ProductVariant){ |
43 | 46 | ||
@@ -49,8 +52,9 @@ class CatalogUrlManager implements UrlRuleInterface { | @@ -49,8 +52,9 @@ class CatalogUrlManager implements UrlRuleInterface { | ||
49 | } | 52 | } |
50 | 53 | ||
51 | 54 | ||
52 | - if(isset($old_item_name[2]) && isset($old_item_name[3]) && isset($old_item_name[4])&& isset($old_item_name[5])){ | ||
53 | - $sku = $old_item_name[2].'/'.$old_item_name[3].'/'.$old_item_name[4].'/'.$old_item_name[5]; | 55 | + if(isset($old_item_name[$count-3]) && isset($old_item_name[$count-2]) && isset($old_item_name[$count-1]) && isset($old_item_name[$count])){ |
56 | + | ||
57 | + $sku = $old_item_name[$count-3].'/'.$old_item_name[$count-2].'/'.$old_item_name[$count-1].'/'.$old_item_name[$count]; | ||
54 | $product_variant = ProductVariant::find()->where(['sku'=>$sku])->one(); | 58 | $product_variant = ProductVariant::find()->where(['sku'=>$sku])->one(); |
55 | if($product_variant instanceof ProductVariant){ | 59 | if($product_variant instanceof ProductVariant){ |
56 | 60 | ||
@@ -61,11 +65,53 @@ class CatalogUrlManager implements UrlRuleInterface { | @@ -61,11 +65,53 @@ class CatalogUrlManager implements UrlRuleInterface { | ||
61 | } | 65 | } |
62 | } | 66 | } |
63 | 67 | ||
64 | - if(isset($old_item_name[2]) && isset($old_item_name[3]) && isset($old_item_name[4])){ | ||
65 | - $sku = $old_item_name[2].'/'.$old_item_name[3].'/'.$old_item_name[4]; | 68 | + if(isset($old_item_name[$count-2]) && isset($old_item_name[$count-1]) && isset($old_item_name[$count])){ |
69 | + $sku = $old_item_name[$count-2].'/'.$old_item_name[$count-1].'/'.$old_item_name[$count]; | ||
70 | + $product_variant = ProductVariant::find()->where(['sku'=>$sku])->one(); | ||
71 | + | ||
72 | + if($product_variant instanceof ProductVariant){ | ||
73 | + | ||
74 | + $link = 'product'.'/'. $product_variant->product->alias; | ||
75 | + header("Status: 301"); | ||
76 | + header("Location: http://www.test-22.artweb.com.ua/".$link); | ||
77 | + die(); | ||
78 | + } | ||
79 | + $sku = $old_item_name[$count-2].'/'.$old_item_name[$count-1].' '.$old_item_name[$count]; | ||
80 | + $product_variant = ProductVariant::find()->where(['sku'=>$sku])->one(); | ||
81 | + | ||
82 | + if($product_variant instanceof ProductVariant){ | ||
83 | + $link = 'product'.'/'. $product_variant->product->alias; | ||
84 | + header("Status: 301"); | ||
85 | + header("Location: http://www.test-22.artweb.com.ua/".$link); | ||
86 | + die(); | ||
87 | + } | ||
88 | + | ||
89 | + $sku = $old_item_name[$count-2].'/'.$old_item_name[$count-1].'-'.$old_item_name[$count]; | ||
90 | + $product_variant = ProductVariant::find()->where(['sku'=>$sku])->one(); | ||
91 | + | ||
92 | + if($product_variant instanceof ProductVariant){ | ||
93 | + $link = 'product'.'/'. $product_variant->product->alias; | ||
94 | + header("Status: 301"); | ||
95 | + header("Location: http://www.test-22.artweb.com.ua/".$link); | ||
96 | + die(); | ||
97 | + } | ||
98 | + | ||
99 | + $sku = $old_item_name[$count-2].'/'.$old_item_name[$count-1].'_'.$old_item_name[$count]; | ||
66 | $product_variant = ProductVariant::find()->where(['sku'=>$sku])->one(); | 100 | $product_variant = ProductVariant::find()->where(['sku'=>$sku])->one(); |
67 | 101 | ||
68 | if($product_variant instanceof ProductVariant){ | 102 | if($product_variant instanceof ProductVariant){ |
103 | + $link = 'product'.'/'. $product_variant->product->alias; | ||
104 | + header("Status: 301"); | ||
105 | + header("Location: http://www.test-22.artweb.com.ua/".$link); | ||
106 | + die(); | ||
107 | + } | ||
108 | + | ||
109 | + } | ||
110 | + | ||
111 | + if(isset($old_item_name[$count-1]) && isset($old_item_name[$count])){ | ||
112 | + $sku = $old_item_name[$count-1].'/'.$old_item_name[$count]; | ||
113 | + $product_variant = ProductVariant::find()->where(['sku'=>$sku])->one(); | ||
114 | + if($product_variant instanceof ProductVariant){ | ||
69 | 115 | ||
70 | $link = 'product'.'/'. $product_variant->product->alias; | 116 | $link = 'product'.'/'. $product_variant->product->alias; |
71 | header("Status: 301"); | 117 | header("Status: 301"); |
@@ -74,8 +120,8 @@ class CatalogUrlManager implements UrlRuleInterface { | @@ -74,8 +120,8 @@ class CatalogUrlManager implements UrlRuleInterface { | ||
74 | } | 120 | } |
75 | } | 121 | } |
76 | 122 | ||
77 | - if(isset($old_item_name[2]) && isset($old_item_name[3])){ | ||
78 | - $sku = $old_item_name[2].'/'.$old_item_name[3]; | 123 | + if(isset($old_item_name[$count])){ |
124 | + $sku = $old_item_name[$count]; | ||
79 | $product_variant = ProductVariant::find()->where(['sku'=>$sku])->one(); | 125 | $product_variant = ProductVariant::find()->where(['sku'=>$sku])->one(); |
80 | if($product_variant instanceof ProductVariant){ | 126 | if($product_variant instanceof ProductVariant){ |
81 | 127 | ||
@@ -88,7 +134,9 @@ class CatalogUrlManager implements UrlRuleInterface { | @@ -88,7 +134,9 @@ class CatalogUrlManager implements UrlRuleInterface { | ||
88 | } | 134 | } |
89 | } | 135 | } |
90 | 136 | ||
91 | - | 137 | + /** |
138 | + * end linija-svitla.ua only | ||
139 | + */ | ||
92 | 140 | ||
93 | 141 | ||
94 | 142 |
frontend/views/event/_product_item.php
@@ -28,7 +28,7 @@ $category = $model->category; | @@ -28,7 +28,7 @@ $category = $model->category; | ||
28 | } | 28 | } |
29 | 29 | ||
30 | ?> | 30 | ?> |
31 | - <?= \common\components\artboximage\ArtboxImageHelper::getImage($model->enabledVariants[ 0 ]->imageUrl, 'list', [ | 31 | + <?= \common\components\artboximage\ArtboxImageHelper::getImage($model->variant->imageUrl, 'list', [ |
32 | 'alt' => $model->category->name . ' ' . $model->fullname, | 32 | 'alt' => $model->category->name . ' ' . $model->fullname, |
33 | 'title' => $model->category->name . ' ' . $model->fullname, | 33 | 'title' => $model->category->name . ' ' . $model->fullname, |
34 | 'class' => 'selected' | 34 | 'class' => 'selected' |
@@ -92,10 +92,10 @@ $category = $model->category; | @@ -92,10 +92,10 @@ $category = $model->category; | ||
92 | // есть скидка | 92 | // есть скидка |
93 | echo '<p class="cost">'; | 93 | echo '<p class="cost">'; |
94 | if($model->enabledVariants[ 0 ]->price_old != 0 && $model->enabledVariants[ 0 ]->price_old != $model->enabledVariants[ 0 ]->price) { | 94 | if($model->enabledVariants[ 0 ]->price_old != 0 && $model->enabledVariants[ 0 ]->price_old != $model->enabledVariants[ 0 ]->price) { |
95 | - echo '<strike><span id=\'old_cost\' itemprop="price">' . $model->enabledVariants[0]->price_old . '</span> грн.</strike> '; | ||
96 | - echo $model->enabledVariants[0]->price . ' <span>грн.</span></p>'; | 95 | + echo '<strike><span id=\'old_cost\' itemprop="price">' . $model->variant->price_old . '</span> грн.</strike> '; |
96 | + echo $model->variant->price . ' <span>грн.</span></p>'; | ||
97 | } else { | 97 | } else { |
98 | - echo '<span itemprop="price">'.$model->enabledVariants[0]->price . ' </span><span>грн.</span></p>'; | 98 | + echo '<span itemprop="price">'.$model->variant->price . ' </span><span>грн.</span></p>'; |
99 | } | 99 | } |
100 | echo '<meta itemprop="priceCurrency" content = "UAH">'; | 100 | echo '<meta itemprop="priceCurrency" content = "UAH">'; |
101 | echo '</div>'; | 101 | echo '</div>'; |