Commit 0ff57d01878a7200f6811640b172db4ad0fb554f

Authored by Administrator
1 parent f5e792e6

image size

Showing 1 changed file with 171 additions and 0 deletions   Show diff stats
frontend/controllers/SiteController.php
... ... @@ -2,6 +2,7 @@
2 2  
3 3 namespace frontend\controllers;
4 4  
  5 +use common\modules\product\models\Category;
5 6 use Yii;
6 7 use yii\web\Controller;
7 8 use common\models\Page;
... ... @@ -51,6 +52,176 @@ class SiteController extends Controller
51 52 ]);
52 53 }
53 54  
  55 + public function actionPriceparam ()
  56 + {
  57 + if (! $catalog = Category::find ()
  58 + ->where (['translit' => $_GET['translit']])
  59 + ->with ('parent')
  60 + ->one ()
  61 + )
  62 + {
  63 + throw new HttpException(404, 'Данной странице не существует!');
  64 + }
  65 +
  66 + //var_dump();die;
  67 +
  68 + $products = Products::find ()->where (['catalog_id' => $catalog->id])->all();
  69 + if (isset($_GET['count'])){
  70 +
  71 + print (count($products));die;
  72 +
  73 + }
  74 +//var_dump($products);die();
  75 + set_time_limit (0);
  76 + header ("Content-Type: text/xml");
  77 + print '<?xml version="1.0" encoding="UTF-8" ?>';
  78 + print "<price>";
  79 + print "<date>" . date ("Y-m-d h:m") . "</date>";
  80 + print "<firmName>Rukzachok</firmName>";
  81 + print "<firmId></firmId>";
  82 + print "<rate></rate>";
  83 + print "<categories>";
  84 +
  85 + print "<category>";
  86 + print "<id>" . $catalog->id . "</id>";
  87 + print "<parentId></parentId>";
  88 + print "<name>" . $catalog->name . "</name>";
  89 + print "</category>";
  90 +
  91 +
  92 + print "</categories>";
  93 + print "<items>";
  94 + foreach ($products as $product)
  95 + {
  96 + $color = Mod::find()->where ('
  97 + (onstock_status_id > 0 OR is_always_active > 0)
  98 + AND cost > 0
  99 + AND status = 1
  100 + ')->where(['product_id' => $product->id])->all();
  101 +
  102 + $brend = Brends::find()->where(['id' => $product->brend_id])->one();
  103 + //$brends = Brends::find()->orderBy('sort ASC')->all();
  104 +
  105 + //var_dump($brend);die;
  106 +
  107 + foreach($color as $v) {
  108 +
  109 + $col = $v['color'];
  110 + $pr = $v['cost'];
  111 + $old_pr = $v['old_cost'];
  112 + print "<item>";
  113 + print "<id>" . htmlspecialchars ($v['id']) . "</id>";
  114 + print "<categoryId>" . htmlspecialchars ($product->catalog_id) . "</categoryId>";
  115 + print "<vendor>".$brend['name']."</vendor>";
  116 + print "<code>" . htmlspecialchars ($v['art']) . "</code>";
  117 + print "<typeprefix>" . htmlspecialchars (substr($catalog->name, 0,-2)) ." </typeprefix>";
  118 + print "<name>" . htmlspecialchars ($product->name) ." </name>";
  119 + print "<param>". $col . " </param>";
  120 + print "<description>" . htmlspecialchars ($product->body_ru) . "</description>";
  121 + print "<url>http://rukzachok.com.ua/products/" . htmlspecialchars ($_GET['translit']) . "/" . htmlspecialchars ($product->translit). "</url>";
  122 + print "<image>http://rukzachok.com.ua/upload/mod/big/" . $v['image'] . "</image>";
  123 + print "<priceRUAH>" . $pr . "</priceRUAH>";
  124 + print "<oldprice>" . $old_pr . "</oldprice>";
  125 + print "<priceRUSD></priceRUSD>";
  126 + print "<stock>В наличии</stock>";
  127 + print "<guarantee></guarantee>";
  128 + print "</item>";
  129 +
  130 + }
  131 + }
  132 +
  133 +
  134 + print "</items>";
  135 +
  136 + print "</price>";
  137 +
  138 +
  139 + }
  140 +
  141 + public function actionPrice()
  142 + {
  143 +
  144 + if (! $catalog = Category::find ()
  145 + ->where (['translit' => $_GET['translit']])
  146 + ->with ('parent')
  147 + ->one ()
  148 + )
  149 + {
  150 + throw new HttpException(404, 'Данной странице не существует!');
  151 + }
  152 +
  153 +
  154 +
  155 + $products = Products::find ()->where (['catalog_id' => $catalog->id])->all();
  156 + if (isset($_GET['count'])){
  157 +
  158 + print (count($products));die;
  159 +
  160 + }
  161 +//var_dump($products);die();
  162 + set_time_limit (0);
  163 + header ("Content-Type: text/xml");
  164 + print '<?xml version="1.0" encoding="UTF-8" ?>';
  165 + print "<price>";
  166 + print "<date>" . date ("Y-m-d h:m") . "</date>";
  167 + print "<firmName>Rukzachok</firmName>";
  168 + print "<firmId></firmId>";
  169 + print "<rate></rate>";
  170 + print "<categories>";
  171 +
  172 + print "<category>";
  173 + print "<id>" . $catalog->id . "</id>";
  174 + print "<parentId></parentId>";
  175 + print "<name>" . $catalog->name . "</name>";
  176 + print "</category>";
  177 +
  178 + print "</categories>";
  179 + print "<items>";
  180 + foreach ($products as $product)
  181 + {
  182 + $color = Mod::find()->where ('
  183 + (onstock_status_id > 0 OR is_always_active > 0)
  184 + AND cost > 0
  185 + AND status = 1
  186 + ')->where(['product_id' => $product->id])->all();
  187 +
  188 + $brend = Brends::find()->where(['id' => $product->brend_id])->one();
  189 + //$brends = Brends::find()->orderBy('sort ASC')->all();
  190 +
  191 + //var_dump($brend);die;
  192 +
  193 + foreach($color as $v) {
  194 +
  195 + $col = $v['color'];
  196 + $pr = $v['cost'];
  197 + $old_pr = $v['old_cost'];
  198 +
  199 + print "<item>";
  200 + print "<id>" . htmlspecialchars ($v['id']) . "</id>";
  201 + print "<categoryId>" . htmlspecialchars ($product->catalog_id) . "</categoryId>";
  202 + print "<vendor>".$brend['name']."</vendor>";
  203 + print "<code>" . htmlspecialchars ($v['art']) . "</code>";
  204 + print "<name>" . htmlspecialchars ($product->name) ." ". $col . " </name>";
  205 + print "<description>" . htmlspecialchars ($product->body_ru) . "</description>";
  206 + print "<url>http://rukzachok.com.ua/products/" . htmlspecialchars ($_GET['translit']) . "/" . htmlspecialchars ($product->translit) . "</url>";
  207 + print "<image>http://rukzachok.com.ua/upload/mod/big/" . $v['image'] . "</image>";
  208 + print "<priceRUAH>" . $pr . "</priceRUAH>";
  209 + print "<oldprice>" . $old_pr . "</oldprice>";
  210 + print "<priceRUSD></priceRUSD>";
  211 + print "<stock>В наличии</stock>";
  212 + print "<guarantee></guarantee>";
  213 + print "</item>";
  214 +
  215 + }
  216 + }
  217 +
  218 +
  219 + print "</items>";
  220 +
  221 + print "</price>";
  222 +
  223 +
  224 + }
54 225  
55 226  
56 227 }
57 228 \ No newline at end of file
... ...