Commit dc9ffa3cb5cac1a6d0a5dd40b966164b5f64a8b3

Authored by Administrator
1 parent 2e531a6a

big commti

frontend/config/main.php
... ... @@ -75,6 +75,7 @@ return [
75 75  
76 76 ]
77 77 ],
  78 +
78 79 'cabinet/main' => '/cabinet/main',
79 80 'priceparam.xml' => 'site/priceparam',
80 81 'price.xml' => 'site/price',
... ...
frontend/controllers/SiteController.php
... ... @@ -2,20 +2,27 @@
2 2  
3 3 namespace frontend\controllers;
4 4  
5   -use common\components\Mailer;
  5 +
6 6 use Yii;
7 7 use common\models\LoginForm;
8 8 use frontend\models\PasswordResetRequestForm;
9 9 use frontend\models\ResetPasswordForm;
10 10 use frontend\models\SignupForm;
11   -use frontend\models\ContactForm;
  11 +
12 12 use yii\base\InvalidParamException;
  13 +use yii\helpers\ArrayHelper;
13 14 use yii\web\BadRequestHttpException;
14 15 use yii\web\Controller;
15   -use yii\filters\VerbFilter;
16   -use yii\filters\AccessControl;
  16 +
17 17 use yii\web\Response;
18 18 use yii\widgets\ActiveForm;
  19 +
  20 +use common\modules\product\models\CategorySearch;
  21 +use common\modules\product\models\Product;
  22 +use common\modules\product\models\ProductVariant;
  23 +
  24 +
  25 +
19 26 class SiteController extends Controller
20 27 {
21 28  
... ... @@ -146,4 +153,161 @@ class SiteController extends Controller
146 153 'model' => $model,
147 154 ]);
148 155 }
  156 +
  157 + public function actionPriceparam ()
  158 + {
  159 + $category_alias = Yii::$app->request->get('category');
  160 + $is_count = Yii::$app->request->get('count', false);
  161 +
  162 + if ( !($category = CategorySearch::findByAlias($category_alias)))
  163 + {
  164 + throw new HttpException(404, 'Данной страницы не существует!');
  165 + }
  166 +
  167 + $products = $category->products;
  168 +
  169 + if ($is_count) {
  170 + print (count($products));
  171 + exit;
  172 + }
  173 +
  174 + set_time_limit (0);
  175 + header ("Content-Type: text/xml");
  176 + print '<?xml version="1.0" encoding="UTF-8" ?>';
  177 + print "<price>";
  178 + print "<date>" . date ("Y-m-d h:m") . "</date>";
  179 + print "<firmName>www.linija-svitla.ua</firmName>";
  180 + print "<firmId></firmId>";
  181 + print "<rate></rate>";
  182 + print "<categories>";
  183 +
  184 + print "<category>";
  185 + print "<id>" . $category->category_id . "</id>";
  186 + print "<parentId></parentId>";
  187 + print "<name>" . $category->name . "</name>";
  188 + print "</category>";
  189 +
  190 +
  191 + print "</categories>";
  192 + print "<items>";
  193 + /** @var Product $product */
  194 + foreach ($products as $product) {
  195 + /** @var ProductVariant $variant */
  196 + foreach ($product->enabledVariants as $variant) {
  197 +
  198 + print "<item>";
  199 + print "<id>" . htmlspecialchars($variant->product_variant_id) . "</id>";
  200 + print "<categoryId>" . htmlspecialchars($product->category->category_id) . "</categoryId>";
  201 + print "<vendor>" . $product->brand->name . "</vendor>";
  202 + print "<code>" . htmlspecialchars($variant->sku) . "</code>";
  203 + print "<typeprefix>" . htmlspecialchars(substr($category->name, 0, -2)) . " </typeprefix>";
  204 + print "<name>" . htmlspecialchars($product->name) . " </name>";
  205 + print "<param>" . $variant->name . " </param>";
  206 + print "<description>" . htmlspecialchars($product->description) . "</description>";
  207 + print "<url>http://www.linija-svitla.ua{$product->url}#{$variant->product_variant_id}</url>";
  208 + print "<image>http://www.linija-svitla.ua{$variant->imageUrl}</image>";
  209 + print "<priceRUAH>" . $variant->price . "</priceRUAH>";
  210 + print "<oldprice>" . $variant->price_old . "</oldprice>";
  211 + print "<priceRUSD></priceRUSD>";
  212 + print "<stock>В наличии</stock>";
  213 + print "<guarantee></guarantee>";
  214 + print "</item>";
  215 + }
  216 + }
  217 + print "</items>";
  218 +
  219 + print "</price>";
  220 + }
  221 +
  222 + public function actionPrice()
  223 + {
  224 +
  225 +
  226 + $category_alias = Yii::$app->request->get('category');
  227 + $is_count = Yii::$app->request->get('count', false);
  228 +
  229 + if ( !($category = CategorySearch::findByAlias($category_alias)))
  230 + {
  231 + throw new HttpException(404, 'Данной страницы не существует!');
  232 + }
  233 +
  234 + $products = $category->getProducts()->with(['filters','filters.group'])->all();
  235 +
  236 + if ($is_count) {
  237 + print (count($products));
  238 + exit;
  239 + }
  240 +
  241 +
  242 +//var_dump($products);die();
  243 + set_time_limit (0);
  244 + header ("Content-Type: text/xml");
  245 + print '<?xml version="1.0" encoding="UTF-8" ?>';
  246 + print "<price>";
  247 + print "<date>" . date ("Y-m-d h:m") . "</date>";
  248 + print "<firmName>www.linija-svitla.ua</firmName>";
  249 + print "<firmId></firmId>";
  250 + print "<rate></rate>";
  251 + print "<categories>";
  252 +
  253 + print "<category>";
  254 + print "<id>" . $category->category_id . "</id>";
  255 + print "<parentId></parentId>";
  256 + print "<name>" . $category->name . "</name>";
  257 + print "</category>";
  258 +
  259 + print "</categories>";
  260 + print "<items>";
  261 + /** @var Product $product */
  262 + foreach ($products as $product)
  263 + {
  264 +
  265 +
  266 + print "<item>";
  267 + print "<id>" . htmlspecialchars($product->variant->product_variant_id) . "</id>";
  268 + print "<categoryId>" . htmlspecialchars($product->category->category_id) . "</categoryId>";
  269 + print "<vendor>" . $product->brand->name . "</vendor>";
  270 + print "<code>" . htmlspecialchars($product->variant->sku) . "</code>";
  271 + print "<name>" . htmlspecialchars($product->name)." " .htmlspecialchars($product->variant->name). " </name>";
  272 + print "<description>" . htmlspecialchars($product->description) . "</description>";
  273 + print "<url>http://www.linija-svitla.ua{$product->url}#{$product->variant->product_variant_id}</url>";
  274 + print "<image>http://www.linija-svitla.ua{$product->variant->imageUrl}</image>";
  275 + print "<priceRUAH>" . $product->variant->price . "</priceRUAH>";
  276 + print "<oldprice>" . $product->variant->price_old . "</oldprice>";
  277 + print "<param name='Тип'>{$product->category->name}</param>";
  278 + foreach( $product->filters as $filter){
  279 + if($filter->group->name == "Назначение:"){
  280 + print "<param name='Назначение'>{$filter->name}</param>";
  281 + }
  282 + if($filter->group->name == "Стиль:"){
  283 + print "<param name='Стиль'>{$filter->name}</param>";
  284 + }
  285 + if($filter->group->name == "Количество лампочек:"){
  286 + print "<param name='Количество источников света'>{$filter->name}</param>";
  287 + }
  288 + if($filter->group->name == "Тип источника света:"){
  289 + print "<param name='Тип источника освещения'>{$filter->name}</param>";
  290 + }
  291 + if($filter->group->name == "Цоколь:"){
  292 + print "<param name='Тип цоколя'>{$filter->name}</param>";
  293 + }
  294 + //print "<param name='Монтаж'>Припотолочная</param>";
  295 +
  296 + }
  297 +
  298 + print "<priceRUSD></priceRUSD>";
  299 + print "<stock>В наличии</stock>";
  300 + print "<guarantee></guarantee>";
  301 + print "</item>";
  302 +
  303 +
  304 + }
  305 +
  306 +
  307 + print "</items>";
  308 +
  309 + print "</price>";
  310 +
  311 +
  312 + }
149 313 }
... ...