3f2bc3d0
Administrator
first commit
|
1
|
<?php
|
7ba4acc5
Administrator
after marge
|
2
|
|
3f2bc3d0
Administrator
first commit
|
3
4
|
namespace frontend\controllers;
|
0ff57d01
Administrator
image size
|
5
|
use common\modules\product\models\Category;
|
3f2bc3d0
Administrator
first commit
|
6
|
use Yii;
|
3f2bc3d0
Administrator
first commit
|
7
|
use yii\web\Controller;
|
7ba4acc5
Administrator
after marge
|
8
9
10
11
|
use common\models\Page;
use common\models\News;
use common\models\Catalog;
use common\models\Products;
|
3f2bc3d0
Administrator
first commit
|
12
|
|
3f2bc3d0
Administrator
first commit
|
13
14
|
class SiteController extends Controller
{
|
ccc7a9d3
Karnovsky A
Karnovsky 12052016
|
15
16
17
18
19
20
21
22
23
|
/**
* @inheritdoc
*/
public function actions()
{
return [
'thumb' => 'iutbay\yii2imagecache\ThumbAction',
];
}
|
055ecc3b
Karnovsky A
Karnovsky 11052016
|
24
|
|
3f2bc3d0
Administrator
first commit
|
25
26
|
public function actionIndex()
{
|
055ecc3b
Karnovsky A
Karnovsky 11052016
|
27
|
|
7ba4acc5
Administrator
after marge
|
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
// $catalogs = Catalog::find()->where(['parent_id'=>'0'])->all();
$modelText = Page::find()->where(['translit'=>'home'])->one();
// $news = News::find()->orderBy('id DESC')->limit(4)->all();
// $products_new = Products::find()->where(['new'=>'1'])->orderBy('id DESC')->innerJoinWith(['cost'])->groupBy('id')->limit(4)->all();
// //print_r($products_new);
// $products_top = Products::find()->where(['top'=>'1'])->orderBy('id DESC')->innerJoinWith(['cost'])->groupBy('id')->limit(4)->all();
// //print_r($products_top);
// //$products_sale = Products::find()->where(['sale'=>'1'])->innerJoinWith(['cost'])->orderBy('id DESC')->limit(4)->all();
// $products_akciya = Products::find()->where(['akciya'=>'1'])->innerJoinWith(['cost'])->orderBy('id DESC')->limit(4)->all();
return $this->render('index', [
'text'=>$modelText,
// 'catalogs'=>$catalogs,
// 'news'=>$news,
// 'products_new'=>$products_new,
// 'products_top'=>$products_top,
// 'products_akciya'=>$products_akciya,
|
055ecc3b
Karnovsky A
Karnovsky 11052016
|
44
|
]);
|
3f2bc3d0
Administrator
first commit
|
45
|
}
|
055ecc3b
Karnovsky A
Karnovsky 11052016
|
46
|
|
7ba4acc5
Administrator
after marge
|
47
|
public function actionError(){
|
055ecc3b
Karnovsky A
Karnovsky 11052016
|
48
|
|
7ba4acc5
Administrator
after marge
|
49
50
51
|
return $this->render('error', [
'code'=>Yii::$app->errorHandler->exception->statusCode,
'message'=>Yii::$app->errorHandler->exception->getMessage(),
|
055ecc3b
Karnovsky A
Karnovsky 11052016
|
52
53
54
|
]);
}
|
0ff57d01
Administrator
image size
|
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
|
public function actionPriceparam ()
{
if (! $catalog = Category::find ()
->where (['translit' => $_GET['translit']])
->with ('parent')
->one ()
)
{
throw new HttpException(404, 'Данной странице не существует!');
}
//var_dump();die;
$products = Products::find ()->where (['catalog_id' => $catalog->id])->all();
if (isset($_GET['count'])){
print (count($products));die;
}
//var_dump($products);die();
set_time_limit (0);
header ("Content-Type: text/xml");
print '<?xml version="1.0" encoding="UTF-8" ?>';
print "<price>";
print "<date>" . date ("Y-m-d h:m") . "</date>";
print "<firmName>Rukzachok</firmName>";
print "<firmId></firmId>";
print "<rate></rate>";
print "<categories>";
print "<category>";
print "<id>" . $catalog->id . "</id>";
print "<parentId></parentId>";
print "<name>" . $catalog->name . "</name>";
print "</category>";
print "</categories>";
print "<items>";
foreach ($products as $product)
{
$color = Mod::find()->where ('
(onstock_status_id > 0 OR is_always_active > 0)
AND cost > 0
AND status = 1
')->where(['product_id' => $product->id])->all();
$brend = Brends::find()->where(['id' => $product->brend_id])->one();
//$brends = Brends::find()->orderBy('sort ASC')->all();
//var_dump($brend);die;
foreach($color as $v) {
$col = $v['color'];
$pr = $v['cost'];
$old_pr = $v['old_cost'];
print "<item>";
print "<id>" . htmlspecialchars ($v['id']) . "</id>";
print "<categoryId>" . htmlspecialchars ($product->catalog_id) . "</categoryId>";
print "<vendor>".$brend['name']."</vendor>";
print "<code>" . htmlspecialchars ($v['art']) . "</code>";
print "<typeprefix>" . htmlspecialchars (substr($catalog->name, 0,-2)) ." </typeprefix>";
print "<name>" . htmlspecialchars ($product->name) ." </name>";
print "<param>". $col . " </param>";
print "<description>" . htmlspecialchars ($product->body_ru) . "</description>";
print "<url>http://rukzachok.com.ua/products/" . htmlspecialchars ($_GET['translit']) . "/" . htmlspecialchars ($product->translit). "</url>";
print "<image>http://rukzachok.com.ua/upload/mod/big/" . $v['image'] . "</image>";
print "<priceRUAH>" . $pr . "</priceRUAH>";
print "<oldprice>" . $old_pr . "</oldprice>";
print "<priceRUSD></priceRUSD>";
print "<stock>В наличии</stock>";
print "<guarantee></guarantee>";
print "</item>";
}
}
print "</items>";
print "</price>";
}
public function actionPrice()
{
if (! $catalog = Category::find ()
->where (['translit' => $_GET['translit']])
->with ('parent')
->one ()
)
{
throw new HttpException(404, 'Данной странице не существует!');
}
$products = Products::find ()->where (['catalog_id' => $catalog->id])->all();
if (isset($_GET['count'])){
print (count($products));die;
}
//var_dump($products);die();
set_time_limit (0);
header ("Content-Type: text/xml");
print '<?xml version="1.0" encoding="UTF-8" ?>';
print "<price>";
print "<date>" . date ("Y-m-d h:m") . "</date>";
print "<firmName>Rukzachok</firmName>";
print "<firmId></firmId>";
print "<rate></rate>";
print "<categories>";
print "<category>";
print "<id>" . $catalog->id . "</id>";
print "<parentId></parentId>";
print "<name>" . $catalog->name . "</name>";
print "</category>";
print "</categories>";
print "<items>";
foreach ($products as $product)
{
$color = Mod::find()->where ('
(onstock_status_id > 0 OR is_always_active > 0)
AND cost > 0
AND status = 1
')->where(['product_id' => $product->id])->all();
$brend = Brends::find()->where(['id' => $product->brend_id])->one();
//$brends = Brends::find()->orderBy('sort ASC')->all();
//var_dump($brend);die;
foreach($color as $v) {
$col = $v['color'];
$pr = $v['cost'];
$old_pr = $v['old_cost'];
print "<item>";
print "<id>" . htmlspecialchars ($v['id']) . "</id>";
print "<categoryId>" . htmlspecialchars ($product->catalog_id) . "</categoryId>";
print "<vendor>".$brend['name']."</vendor>";
print "<code>" . htmlspecialchars ($v['art']) . "</code>";
print "<name>" . htmlspecialchars ($product->name) ." ". $col . " </name>";
print "<description>" . htmlspecialchars ($product->body_ru) . "</description>";
print "<url>http://rukzachok.com.ua/products/" . htmlspecialchars ($_GET['translit']) . "/" . htmlspecialchars ($product->translit) . "</url>";
print "<image>http://rukzachok.com.ua/upload/mod/big/" . $v['image'] . "</image>";
print "<priceRUAH>" . $pr . "</priceRUAH>";
print "<oldprice>" . $old_pr . "</oldprice>";
print "<priceRUSD></priceRUSD>";
print "<stock>В наличии</stock>";
print "<guarantee></guarantee>";
print "</item>";
}
}
print "</items>";
print "</price>";
}
|
ccc7a9d3
Karnovsky A
Karnovsky 12052016
|
225
226
|
|
7ba4acc5
Administrator
after marge
|
227
|
}
|