diff --git a/frontend/config/main.php b/frontend/config/main.php index c12b1d9..71d4f7c 100755 --- a/frontend/config/main.php +++ b/frontend/config/main.php @@ -75,6 +75,7 @@ return [ ] ], + 'cabinet/main' => '/cabinet/main', 'priceparam.xml' => 'site/priceparam', 'price.xml' => 'site/price', diff --git a/frontend/controllers/SiteController.php b/frontend/controllers/SiteController.php index 37120ce..feb1af0 100755 --- a/frontend/controllers/SiteController.php +++ b/frontend/controllers/SiteController.php @@ -2,20 +2,27 @@ namespace frontend\controllers; -use common\components\Mailer; + use Yii; use common\models\LoginForm; use frontend\models\PasswordResetRequestForm; use frontend\models\ResetPasswordForm; use frontend\models\SignupForm; -use frontend\models\ContactForm; + use yii\base\InvalidParamException; +use yii\helpers\ArrayHelper; use yii\web\BadRequestHttpException; use yii\web\Controller; -use yii\filters\VerbFilter; -use yii\filters\AccessControl; + use yii\web\Response; use yii\widgets\ActiveForm; + +use common\modules\product\models\CategorySearch; +use common\modules\product\models\Product; +use common\modules\product\models\ProductVariant; + + + class SiteController extends Controller { @@ -146,4 +153,161 @@ class SiteController extends Controller 'model' => $model, ]); } + + public function actionPriceparam () + { + $category_alias = Yii::$app->request->get('category'); + $is_count = Yii::$app->request->get('count', false); + + if ( !($category = CategorySearch::findByAlias($category_alias))) + { + throw new HttpException(404, 'Данной страницы не существует!'); + } + + $products = $category->products; + + if ($is_count) { + print (count($products)); + exit; + } + + set_time_limit (0); + header ("Content-Type: text/xml"); + print ''; + print ""; + print "" . date ("Y-m-d h:m") . ""; + print "www.linija-svitla.ua"; + print ""; + print ""; + print ""; + + print ""; + print "" . $category->category_id . ""; + print ""; + print "" . $category->name . ""; + print ""; + + + print ""; + print ""; + /** @var Product $product */ + foreach ($products as $product) { + /** @var ProductVariant $variant */ + foreach ($product->enabledVariants as $variant) { + + print ""; + print "" . htmlspecialchars($variant->product_variant_id) . ""; + print "" . htmlspecialchars($product->category->category_id) . ""; + print "" . $product->brand->name . ""; + print "" . htmlspecialchars($variant->sku) . ""; + print "" . htmlspecialchars(substr($category->name, 0, -2)) . " "; + print "" . htmlspecialchars($product->name) . " "; + print "" . $variant->name . " "; + print "" . htmlspecialchars($product->description) . ""; + print "http://www.linija-svitla.ua{$product->url}#{$variant->product_variant_id}"; + print "http://www.linija-svitla.ua{$variant->imageUrl}"; + print "" . $variant->price . ""; + print "" . $variant->price_old . ""; + print ""; + print "В наличии"; + print ""; + print ""; + } + } + print ""; + + print ""; + } + + public function actionPrice() + { + + + $category_alias = Yii::$app->request->get('category'); + $is_count = Yii::$app->request->get('count', false); + + if ( !($category = CategorySearch::findByAlias($category_alias))) + { + throw new HttpException(404, 'Данной страницы не существует!'); + } + + $products = $category->getProducts()->with(['filters','filters.group'])->all(); + + if ($is_count) { + print (count($products)); + exit; + } + + +//var_dump($products);die(); + set_time_limit (0); + header ("Content-Type: text/xml"); + print ''; + print ""; + print "" . date ("Y-m-d h:m") . ""; + print "www.linija-svitla.ua"; + print ""; + print ""; + print ""; + + print ""; + print "" . $category->category_id . ""; + print ""; + print "" . $category->name . ""; + print ""; + + print ""; + print ""; + /** @var Product $product */ + foreach ($products as $product) + { + + + print ""; + print "" . htmlspecialchars($product->variant->product_variant_id) . ""; + print "" . htmlspecialchars($product->category->category_id) . ""; + print "" . $product->brand->name . ""; + print "" . htmlspecialchars($product->variant->sku) . ""; + print "" . htmlspecialchars($product->name)." " .htmlspecialchars($product->variant->name). " "; + print "" . htmlspecialchars($product->description) . ""; + print "http://www.linija-svitla.ua{$product->url}#{$product->variant->product_variant_id}"; + print "http://www.linija-svitla.ua{$product->variant->imageUrl}"; + print "" . $product->variant->price . ""; + print "" . $product->variant->price_old . ""; + print "{$product->category->name}"; + foreach( $product->filters as $filter){ + if($filter->group->name == "Назначение:"){ + print "{$filter->name}"; + } + if($filter->group->name == "Стиль:"){ + print "{$filter->name}"; + } + if($filter->group->name == "Количество лампочек:"){ + print "{$filter->name}"; + } + if($filter->group->name == "Тип источника света:"){ + print "{$filter->name}"; + } + if($filter->group->name == "Цоколь:"){ + print "{$filter->name}"; + } + //print "Припотолочная"; + + } + + print ""; + print "В наличии"; + print ""; + print ""; + + + } + + + print ""; + + print ""; + + + } } -- libgit2 0.21.4