public function up()
 {
     $submissionObject = Object::getForClass(\app\models\Submission::className());
     /** @var PropertyHandler $propertyHandler */
     $propertyHandler = PropertyHandler::findOne(['name' => 'Text']);
     $this->addColumn(Review::tableName(), 'submission_id', 'INT UNSIGNED NOT NULL');
     $form = new \app\models\Form();
     $form->name = 'Review form';
     $form->email_notification_addresses = '';
     $form->email_notification_view = '@app/modules/review/views/review-email-template.php';
     $form->save(false, ['name', 'email_notification_addresses', 'email_notification_view']);
     $propertyGroup = new PropertyGroup();
     $propertyGroup->attributes = ['object_id' => $form->object->id, 'name' => 'Review form additional properties', 'hidden_group_title' => 1];
     $propertyGroup->save(true, ['object_id', 'name', 'hidden_group_title']);
     $nameProperty = new Property();
     $nameProperty->attributes = ['property_group_id' => $propertyGroup->id, 'name' => 'Name', 'key' => 'name', 'property_handler_id' => $propertyHandler->id, 'handler_additional_params' => '{}', 'is_eav' => 1];
     $nameProperty->save(true, ['property_group_id', 'name', 'key', 'property_handler_id', 'is_eav', 'handler_additional_params']);
     $phoneProperty = new Property();
     $phoneProperty->attributes = ['property_group_id' => $propertyGroup->id, 'name' => 'Phone', 'key' => 'phone', 'property_handler_id' => $propertyHandler->id, 'handler_additional_params' => '{}', 'is_eav' => 1];
     $phoneProperty->save(true, ['property_group_id', 'name', 'key', 'property_handler_id', 'is_eav', 'handler_additional_params']);
     $objectPropertyGroup = new ObjectPropertyGroup();
     $objectPropertyGroup->attributes = ['object_id' => $form->object->id, 'object_model_id' => $form->id, 'property_group_id' => $propertyGroup->id];
     $objectPropertyGroup->save(true, ['object_id', 'object_model_id', 'property_group_id']);
     $reviews = Review::find()->all();
     foreach ($reviews as $review) {
         $submission = new \app\models\Submission();
         $submission->form_id = $form->id;
         $submission->processed_by_user_id = $review->author_user_id;
         $submission->date_received = $review->date_submitted;
         $submission->save(false, ['form_id', 'processed_by_user_id', 'date_received']);
         $review->submission_id = $this->db->lastInsertID;
         $review->save(true, ['submission_id']);
         $this->insert(ObjectPropertyGroup::tableName(), ['object_id' => $submissionObject->id, 'object_model_id' => $submission->id, 'property_group_id' => $propertyGroup->id]);
         $this->insert($submissionObject->eav_table_name, ['object_model_id' => $submission->id, 'property_group_id' => $propertyGroup->id, 'key' => $nameProperty->key, 'value' => $review->author_name]);
         $this->insert($submissionObject->eav_table_name, ['object_model_id' => $submission->id, 'property_group_id' => $propertyGroup->id, 'key' => $phoneProperty->key, 'value' => $review->author_phone]);
     }
     $this->dropColumn(Review::tableName(), 'date_submitted');
     $this->dropColumn(Review::tableName(), 'author_user_id');
     $this->dropColumn(Review::tableName(), 'author_name');
     $this->dropColumn(Review::tableName(), 'author_phone');
     $this->dropColumn(Review::tableName(), 'rate');
     $this->renameColumn(Review::tableName(), 'text', 'review_text');
     $this->alterColumn(Review::tableName(), 'rating_id', 'CHAR(32)');
     $this->update(BackendMenu::tableName(), ['route' => 'review/backend-rating/index'], ['route' => 'backend/rating/index']);
     $this->update(BackendMenu::tableName(), ['route' => 'review/backend-review/index'], ['name' => 'Reviews']);
     $this->delete(BackendMenu::tableName(), ['route' => ['review/backend/products', 'review/backend/pages']]);
     $this->alterColumn(RatingValues::tableName(), 'rating_id', 'CHAR(32) NOT NULL');
     $this->alterColumn(RatingValues::tableName(), 'object_id', 'INT UNSIGNED NOT NULL');
     $this->alterColumn(RatingValues::tableName(), 'object_model_id', 'INT UNSIGNED NOT NULL');
     $this->alterColumn(RatingValues::tableName(), 'rating_item_id', 'INT UNSIGNED NOT NULL');
     $this->alterColumn(RatingValues::tableName(), 'user_id', 'INT UNSIGNED NOT NULL');
     $this->createIndex('ix-rating_values-rating_id', RatingValues::tableName(), 'rating_id');
     $this->createIndex('ix-rating_values-object_id-object_model_id', RatingValues::tableName(), ['object_id', 'object_model_id']);
     $this->createIndex('ix-rating_item-rating_group', RatingItem::tableName(), 'rating_group');
 }
Esempio n. 2
0
 public function run()
 {
     $this->genButton = Html::a(Icon::show('edit') . Yii::t('app', 'Generate'), '#', ['class' => 'btn btn-success', 'id' => 'btn-generate']);
     $parent_id = $this->model->main_category_id;
     $owner_id = $this->model->id;
     $this->addButton = Html::a(Icon::show('plus') . Yii::t('app', 'Add'), Url::toRoute(['/shop/backend-product/edit', 'parent_id' => $parent_id, 'owner_id' => $owner_id, 'returnUrl' => \app\backend\components\Helper::getReturnUrl()]), ['class' => 'btn btn-success', 'id' => 'btn-add']);
     if (!empty($this->footer)) {
         $this->footer = Html::tag('div', $this->addButton . ' ' . $this->genButton, ['class' => 'widget-footer']);
     }
     $this->object = Object::getForClass(get_class($this->model));
     $rest_pg = (new Query())->select('id, name')->from(PropertyGroup::tableName())->where(['object_id' => $this->object->id])->orderBy('sort_order')->all();
     $this->property_groups_to_add = [];
     foreach ($rest_pg as $row) {
         $this->property_groups_to_add[$row['id']] = $row['name'];
     }
     $optionGenerate = Json::decode($this->model->option_generate);
     if (null === PropertyGroup::findOne($optionGenerate['group'])) {
         $this->model->option_generate = $optionGenerate = null;
     }
     $groupModel = null;
     if (isset($optionGenerate['group'])) {
         $groupModel = PropertyGroup::findOne($optionGenerate['group']);
         $properties = Property::getForGroupId($optionGenerate['group']);
     } else {
         $group_ids = array_keys($this->property_groups_to_add);
         $group_id = array_shift($group_ids);
         $groupModel = PropertyGroup::findOne($group_id);
         $properties = Property::getForGroupId($group_id);
     }
     if (is_null($groupModel)) {
         $groupModel = new PropertyGroup();
     }
     return $this->render($this->viewFile, ['model' => $this->model, 'form' => $this->form, 'groups' => $this->property_groups_to_add, 'groupModel' => $groupModel, 'properties' => $properties, 'optionGenerate' => $optionGenerate, 'footer' => $this->footer]);
 }
 public function actionEdit($id = null)
 {
     $model = new PrefilteredPages();
     $model->loadDefaultValues();
     if ($id !== null) {
         $model = PrefilteredPages::findOne($id);
     }
     $static_values_properties = [];
     $property_groups_ids_for_object = (new Query())->select('id')->from(PropertyGroup::tableName())->where(['object_id' => Object::getForClass(Product::className())->id])->column();
     $properties = Property::find()->andWhere(['in', 'property_group_id', $property_groups_ids_for_object])->all();
     foreach ($properties as $prop) {
         /** @var Property $prop */
         $static_values_properties[$prop->id] = ['property' => $prop, 'static_values_select' => PropertyStaticValues::getSelectForPropertyId($prop->id), 'has_static_values' => $prop->has_static_values === 1];
     }
     $post = \Yii::$app->request->post();
     if ($model->load($post) && $model->validate()) {
         $save_result = $model->save();
         if ($save_result) {
             Yii::$app->session->setFlash('info', Yii::t('app', 'Object saved'));
             $returnUrl = Yii::$app->request->get('returnUrl', ['index', 'id' => $model->id]);
             switch (Yii::$app->request->post('action', 'save')) {
                 case 'next':
                     return $this->redirect(['edit', 'returnUrl' => $returnUrl]);
                 case 'back':
                     return $this->redirect($returnUrl);
                 default:
                     return $this->redirect(Url::toRoute(['edit', 'id' => $model->id, 'returnUrl' => $returnUrl]));
             }
             //return $this->redirect(['/backend/prefiltered-pages/edit', 'id' => $model->id]);
         } else {
             \Yii::$app->session->setFlash('error', Yii::t('app', 'Cannot update data'));
         }
     }
     return $this->render('prefiltered-page-form', ['model' => $model, 'static_values_properties' => $static_values_properties]);
 }
 public function actionEdit($id = null)
 {
     $model = new DynamicContent();
     $model->loadDefaultValues();
     if ($id !== null) {
         $model = DynamicContent::findOne($id);
     }
     $static_values_properties = [];
     if (isset($_GET['DynamicContent'])) {
         if (isset($_GET['DynamicContent']['object_id'])) {
             $model->object_id = intval($_GET['DynamicContent']['object_id']);
         }
     }
     $property_groups_ids_for_object = (new Query())->select('id')->from(PropertyGroup::tableName())->where([])->column();
     $properties = Property::find()->where(['has_static_values' => 1, 'has_slugs_in_values' => 1])->andWhere(['in', 'property_group_id', $property_groups_ids_for_object])->all();
     foreach ($properties as $prop) {
         $static_values_properties[$prop->id] = ['has_static_values' => true, 'property' => $prop, 'static_values_select' => PropertyStaticValues::getSelectForPropertyId($prop->id)];
     }
     $post = \Yii::$app->request->post();
     if (isset($_GET['DynamicContent'])) {
         $post = $_GET;
     }
     if ($model->load($post) && $model->validate() && !isset($_GET['DynamicContent'])) {
         $save_result = $model->save();
         if ($save_result) {
             return $this->redirectUser($model->id);
         } else {
             \Yii::$app->session->setFlash('error', Yii::t('app', 'Cannot update data'));
         }
     }
     return $this->render('dynamic-content-form', ['model' => $model, 'static_values_properties' => $static_values_properties]);
 }
 public function actionIndex($category_id = null)
 {
     $searchModel = new Category();
     $searchModel->active = 1;
     $params = Yii::$app->request->get();
     $dataProvider = $searchModel->search($params);
     $selectedCategory = null;
     if ($category_id !== null) {
         $selectedCategory = Category::findById($category_id);
     }
     if ($selectedCategory !== null) {
         if (Yii::$app->request->isPost === true) {
             $newProperty = isset($_GET['add_property_id']) ? Property::findById($_GET['add_property_id']) : null;
             if ($newProperty !== null) {
                 $filterSet = new FilterSets();
                 $filterSet->category_id = $selectedCategory->id;
                 $filterSet->property_id = $newProperty->id;
                 $filterSet->sort_order = 65535;
                 $filterSet->save();
             }
         }
     }
     $groups = PropertyGroup::getForObjectId(Object::getForClass(Product::className())->id, false);
     $propertiesDropdownItems = [];
     foreach ($groups as $group) {
         $item = ['label' => $group->name, 'url' => '#', 'items' => []];
         $properties = Property::getForGroupId($group->id);
         foreach ($properties as $prop) {
             $item['items'][] = ['label' => $prop->name, 'url' => '?category_id=' . $category_id . '&add_property_id=' . $prop->id, 'linkOptions' => ['class' => 'add-property-to-filter-set', 'data-property-id' => $prop->id, 'data-action' => 'post']];
         }
         $propertiesDropdownItems[] = $item;
     }
     return $this->render('index', ['dataProvider' => $dataProvider, 'searchModel' => $searchModel, 'selectedCategory' => $selectedCategory, 'propertiesDropdownItems' => $propertiesDropdownItems]);
 }
Esempio n. 6
0
 public function getData()
 {
     $query = new Query();
     $query->select(Property::tableName() . '.id, ' . Property::tableName() . '.name')->from(Property::tableName());
     $query->leftJoin(PropertyGroup::tableName(), PropertyGroup::tableName() . '.id = ' . Property::tableName() . '.property_group_id');
     $query->andWhere([PropertyGroup::tableName() . '.object_id' => $this->objectId]);
     $command = $query->createCommand();
     $this->data = ArrayHelper::map($command->queryAll(), 'id', 'name');
     return parent::getData();
 }
Esempio n. 7
0
 protected function getProperties()
 {
     $result = [];
     $query = new Query();
     $query->select(Property::tableName() . '.key, ' . Property::tableName() . '.name')->from(Property::tableName());
     $query->innerJoin(PropertyGroup::tableName(), PropertyGroup::tableName() . '.id = ' . Property::tableName() . '.property_group_id');
     $query->andWhere([PropertyGroup::tableName() . '.object_id' => $this->object->id]);
     $command = $query->createCommand();
     return ArrayHelper::map($command->queryAll(), 'key', 'name');
 }
Esempio n. 8
0
 /**
  * @param $objectId
  * @return array
  */
 protected static function getProperties($objectId)
 {
     $properties = [];
     $groups = PropertyGroup::getForObjectId($objectId);
     foreach ($groups as $group) {
         $props = Property::getForGroupId($group->id);
         foreach ($props as $prop) {
             $properties[] = $prop;
         }
     }
     return $properties;
 }
Esempio n. 9
0
 public function actionEdit($id = null)
 {
     $model = new Form();
     if ($id > 0) {
         $model = Form::findOne($id);
     }
     /** @var \app\models\Object $object */
     $object = Object::getForClass(Form::className());
     $propIds = (new Query())->select('property_group_id')->from([ObjectPropertyGroup::tableName()])->where(['and', 'object_id = :object', 'object_model_id = :id'], [':object' => $object->id, ':id' => $id])->column();
     $post = \Yii::$app->request->post();
     $properties = isset($post['Form']['properties']) ? $post['Form']['properties'] : [];
     if ($model->load($post) && $model->validate()) {
         if ($model->save()) {
             $id = $model->id;
             $remove = [];
             $add = [];
             foreach ($propIds as $value) {
                 $key = array_search($value, $properties);
                 if ($key === false) {
                     $remove[] = $value;
                 } else {
                     unset($properties[$key]);
                 }
             }
             foreach ($properties as $value) {
                 $add[] = [$value, $object->id, $id];
             }
             Yii::$app->db->createCommand()->delete(ObjectPropertyGroup::tableName(), ['and', 'object_id = :object', 'object_model_id = :id', ['in', 'property_group_id', $remove]], [':object' => $object->id, ':id' => $id])->execute();
             if (!empty($add)) {
                 Yii::$app->db->createCommand()->batchInsert(ObjectPropertyGroup::tableName(), ['property_group_id', 'object_id', 'object_model_id'], $add)->execute();
             }
             \Yii::$app->session->setFlash('info', Yii::t('app', 'Object saved'));
             $returnUrl = Yii::$app->request->get('returnUrl', ['/backend/form/index', 'id' => $model->id]);
             switch (Yii::$app->request->post('action', 'save')) {
                 case 'next':
                     return $this->redirect(['/backend/form/edit', 'returnUrl' => $returnUrl]);
                 case 'back':
                     return $this->redirect($returnUrl);
                 default:
                     return $this->redirect(Url::toRoute(['/backend/form/edit', 'id' => $model->id, 'returnUrl' => $returnUrl]));
             }
         } else {
             \Yii::$app->session->setFlash('error', Yii::t('app', 'Cannot update data'));
         }
     }
     $items = ArrayHelper::map(PropertyGroup::find()->where('object_id = :object', [':object' => $object->id])->all(), 'id', 'name');
     return $this->render('edit', ['model' => $model, 'items' => $items, 'selected' => $propIds]);
 }
Esempio n. 10
0
 public function run()
 {
     $object = Object::getForClass(\app\models\Form::className());
     $groups = PropertyGroup::getForModel($object->id, $this->formId);
     $view = !empty($this->model->form_view) ? $this->model->form_view : 'form';
     $successView = !empty($this->model->form_success_view) ? $this->model->form_success_view : 'success';
     if (!$this->isModal) {
         echo Html::beginTag('div', ['id' => 'form-info-' . $this->id, 'style' => 'display: none;']);
         echo $this->render($successView);
         echo '</div>';
     }
     echo $this->render($view, ['id' => $this->id, 'model' => $this->model, 'groups' => $groups, 'options' => $this->options]);
     if ($this->isModal) {
         Modal::end();
         Modal::begin(['id' => 'modal-form-info-' . $this->id, 'size' => Modal::SIZE_SMALL, 'header' => $this->statusHeaderName ? $this->statusHeaderName : $this->model->name . ' ' . \Yii::t('app', 'status')]);
         echo $this->render($successView);
         Modal::end();
     }
 }
 public function up()
 {
     $objects = \app\models\Object::find()->asArray()->all();
     foreach ($objects as $object) {
         if ($object['name'] == 'Submission') {
             continue;
         } else {
             if ($object['name'] == 'Form') {
                 $submissionObject = \app\models\Object::findOne(['name' => 'Submission']);
                 $this->addColumn($object['eav_table_name'], 'property_group_id', 'INT UNSIGNED NOT NULL AFTER `object_model_id`');
                 $this->addColumn($submissionObject->eav_table_name, 'property_group_id', 'INT UNSIGNED NOT NULL AFTER `object_model_id`');
                 $groups = \app\models\PropertyGroup::find()->where(['object_id' => $object['id']])->asArray()->all();
                 foreach ($groups as $group) {
                     $forms = \app\models\ObjectPropertyGroup::find()->select('object_model_id')->where(['property_group_id' => $group['id']])->asArray()->all();
                     $formIDs = [];
                     foreach ($forms as $formID) {
                         if (!in_array($formID['object_model_id'], $formIDs)) {
                             $formIDs[] = $formID['object_model_id'];
                         }
                     }
                     $submissionIDs = \app\models\Submission::find()->select('id')->where(['form_id' => $formIDs])->asArray()->all();
                     $subIDs = [];
                     foreach ($submissionIDs as $submission) {
                         $subIDs[] = $submission['id'];
                     }
                     $properties = \app\models\Property::find()->select(['id', 'key'])->where(['property_group_id' => $group['id'], 'is_eav' => 1])->asArray()->all();
                     foreach ($properties as $property) {
                         $this->update($submissionObject->eav_table_name, ['property_group_id' => $group['id']], ['key' => $property['key']]);
                     }
                 }
             } else {
                 $this->addColumn($object['eav_table_name'], 'property_group_id', 'INT UNSIGNED NOT NULL AFTER `object_model_id`');
                 $groups = \app\models\PropertyGroup::find()->where(['object_id' => $object['id']])->asArray()->all();
                 foreach ($groups as $group) {
                     $properties = \app\models\Property::find()->select(['id', 'key'])->where(['property_group_id' => $group['id'], 'is_eav' => 1])->asArray()->all();
                     foreach ($properties as $property) {
                         $this->update($object['eav_table_name'], ['property_group_id' => $group['id']], ['key' => $property['key']]);
                     }
                 }
             }
         }
     }
 }
Esempio n. 12
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     $this->object = Object::getForClass(get_class($this->model));
     $cacheKey = 'PropertiesWidget: ' . get_class($this->model) . ':' . $this->model->id;
     $data = Yii::$app->cache->get($cacheKey);
     if ($data === false) {
         $this->objectPropertyGroups = ObjectPropertyGroup::getForModel($this->model);
         $addedPropertyGroupsIds = [];
         foreach ($this->objectPropertyGroups as $opg) {
             $addedPropertyGroupsIds[] = $opg->property_group_id;
         }
         $restPg = (new Query())->select('id, name')->from(PropertyGroup::tableName())->where(['object_id' => $this->object->id])->andWhere(['not in', 'id', $addedPropertyGroupsIds])->orderBy('sort_order')->all();
         $this->propertyGroupsToAdd = ArrayHelper::map($restPg, 'id', 'name');
         Yii::$app->cache->set($cacheKey, ['objectPropertyGroups' => $this->objectPropertyGroups, 'propertyGroupsToAdd' => $this->propertyGroupsToAdd], 86400, new TagDependency(['tags' => [ActiveRecordHelper::getCommonTag(get_class($this->model)), ActiveRecordHelper::getCommonTag(PropertyGroup::className()), ActiveRecordHelper::getCommonTag(Property::className())]]));
     } else {
         $this->objectPropertyGroups = $data['objectPropertyGroups'];
         $this->propertyGroupsToAdd = $data['propertyGroupsToAdd'];
     }
     return $this->render($this->viewFile, ['model' => $this->model, 'object' => $this->object, 'object_property_groups' => $this->objectPropertyGroups, 'property_groups_to_add' => $this->propertyGroupsToAdd, 'form' => $this->form, 'widget_id' => $this->getId()]);
 }
 public function actionConfigure()
 {
     if (\Yii::$app->request->isPost) {
         foreach (\Yii::$app->request->post('guidSelect', []) as $key => $value) {
             $item = CommercemlGuid::findOne(['id' => $key, 'type' => 'PROPERTY']);
             if (!empty($item)) {
                 $item->model_id = $value;
                 $item->save();
             }
         }
         if (null !== ($file = UploadedFile::getInstanceByName('cmlFile'))) {
             $xmlReader = new XmlFileReader($file->tempName);
             foreach ($xmlReader->getProperties() as $item) {
                 $model = CommercemlGuid::findOne(['guid' => $item[XmlFileReader::ELEMENT_ID]]);
                 if (empty($model)) {
                     $guid = new CommercemlGuid();
                     $guid->type = 'PROPERTY';
                     $guid->guid = $item[XmlFileReader::ELEMENT_ID];
                     $guid->name = $item[XmlFileReader::ELEMENT_NAIMENOVANIE];
                     $guid->model_id = 0;
                     $guid->save();
                 }
             }
         }
         return $this->redirect('', 301);
     }
     $properties = array_reduce(CommercemlGuid::find()->where(['type' => 'PROPERTY'])->asArray()->all(), function ($result, $item) {
         $result[$item['guid']] = $item;
         return $result;
     }, []);
     $propertiesGroups = array_reduce(PropertyGroup::findAll(['object_id' => 3]), function ($result, $item) {
         return array_reduce($item->properties, function ($result, $item) {
             if ($item->is_eav || $item->has_static_values) {
                 $result[] = ['id' => $item->id, 'name' => $item->name];
             }
             return $result;
         }, $result);
     }, [['id' => 0, 'name' => '']]);
     return $this->render('configure', ['props' => $properties, 'propsGroups' => $propertiesGroups]);
 }
 /**
  * @inheritdoc
  */
 public function run()
 {
     if (null === ($form = Form::findById($this->formId)) || null === $this->model || null === $this->model->object) {
         throw new InvalidParamException();
     }
     if ($this->registerCanonical === true) {
         $this->getView()->registerLinkTag(['rel' => 'canonical', 'href' => ObjectRule::canonical($this->additionalParams)], 'canonical');
     }
     $formObject = Object::getForClass(Form::className());
     $groups = PropertyGroup::getForModel($formObject->id, $form->id);
     $models = Review::getForObjectModel($this->model->id, $this->model->object->id, $form->id);
     $review = new Review(['scenario' => 'check']);
     $review->useCaptcha = $this->useCaptcha;
     /** @var $module \app\modules\review\ReviewModule */
     $module = Yii::$app->getModule('review');
     $maxPerPage = $module->maxPerPage;
     $pageSize = $module->pageSize;
     if ($pageSize > $maxPerPage) {
         $pageSize = $maxPerPage;
     }
     $this->additionalParams['review-page'] = Yii::$app->request->get('review-page');
     $this->additionalParams['review-per-page'] = Yii::$app->request->get('review-per-page');
     return $this->render($this->viewFile, ['reviews' => new ArrayDataProvider(['id' => 'review', 'allModels' => $models, 'pagination' => ['pageSize' => $pageSize, 'params' => $this->additionalParams], 'sort' => ['attributes' => ['submission_id'], 'defaultOrder' => ['submission_id' => $this->sort]]]), 'objectModel' => $this->model, 'model' => $form, 'review' => $review, 'groups' => $groups, 'ratingGroupName' => $this->ratingGroupName, 'useCaptcha' => $this->useCaptcha, 'additionalParams' => $this->additionalParams]);
 }
Esempio n. 15
0
 * @var yii\web\View $this
 * @var app\backgroundtasks\models\Task $searchModel
 * @var $review \app\modules\review\models\Review
 */
use kartik\helpers\Html;
use app\models\Object;
use app\models\PropertyGroup;
use app\models\Property;
use app\models\Form;
use kartik\icons\Icon;
use yii\widgets\ActiveForm;
use app\modules\review\models\Review;
$this->title = Yii::t('app', 'Review show');
$this->params['breadcrumbs'] = [['label' => Yii::t('app', 'Reviews'), 'url' => ['index']], $this->title];
$formObject = Object::getForClass(Form::className());
$groups = PropertyGroup::getForModel($formObject->id, $review->submission->form_id);
$review->submission->getPropertyGroups(true);
?>
<div class="review-show">
    <section id="widget-grid">
        <div class="row">
            <article class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                <div class="jarviswidget">
                    <header>
                        <h2><i class="fa fa-cubes"></i> <?php 
echo Yii::t('app', 'Review data');
?>
</h2>
                    </header>
                    <div class="widget-body">
                        <div class="form-group field-page-name">
Esempio n. 16
0
$feed_settings['product_fields'] = (new \app\modules\shop\models\Product())->attributeLabels();
$feed_settings['relations_keys'] = array_combine(array_keys($feed_relations), array_keys($feed_relations));
$feed_settings['relations_map'] = [];
foreach ($feed_relations as $key => $value) {
    $_fields = (new $value())->attributeLabels();
    $feed_settings['relations_map'][$key] = ['fields' => $_fields, 'html' => array_reduce($_fields, function ($result, $i) {
        $result .= '<option value="' . addslashes(htmlspecialchars($i)) . '">' . addslashes(htmlspecialchars($i)) . '</option>';
        return $result;
    }, '')];
}
if (true === isset($feed_settings['relations_map']['getImage'])) {
    $feed_settings['relations_map']['getImage']['fields']['file'] = Yii::t('app', 'File');
    $feed_settings['relations_map']['getImage']['html'] .= '<option value="file">' . Yii::t('app', 'File') . '</option>';
}
$prop_group = \app\models\Object::getForClass(\app\modules\shop\models\Product::className())->id;
$provider = (new \yii\db\Query())->select(['pg.name as pgname', 'p.name', 'p.id', 'p.handler_additional_params'])->from(\app\models\Property::tableName() . ' as p', \app\models\PropertyGroup::tableName() . 'as pg')->leftJoin(\app\models\PropertyGroup::tableName() . 'as pg', 'pg.id=p.property_group_id')->where(['pg.object_id' => $prop_group]);
$prop_group = $provider->all();
$feed_settings['properties_map'] = ['html' => '', 'fields' => []];
$feed_settings['properties_map'] = array_reduce(array_reduce($prop_group, function ($result, $i) {
    if (isset($result[$i['pgname']])) {
        $result[$i['pgname']]['html'] .= '<option value="' . addslashes(htmlspecialchars($i['id'])) . '">' . addslashes(htmlspecialchars($i['name'])) . '</option>';
        $result[$i['pgname']]['fields'][$i['pgname']][$i['id']] = $i['name'];
        $result[$i['pgname']]['name'] = $i['pgname'];
    }
    return $result;
}, array_fill_keys(array_unique(array_column($prop_group, 'pgname')), ['fields' => [], 'html' => '', 'name' => ''])), function ($result, $i) {
    $result['fields'] = array_replace($result['fields'], $i['fields']);
    $result['html'] .= '<optgroup label="' . addslashes(addslashes($i['name'])) . '">' . addslashes(addslashes($i['html'])) . '</optgroup>';
    return $result;
}, $feed_settings['properties_map']);
?>
Esempio n. 17
0
 /**
  * @return PropertyGroup|null
  */
 public function getGroup()
 {
     return $this->hasOne(PropertyGroup::className(), ['id' => 'property_group_id']);
 }
Esempio n. 18
0
        </div>
        <div class="form-group">
            <?php 
echo Html::a(Yii::t('app', 'Your orders'), ['/shop/orders/list']);
?>
        </div>

    </div>
    <div class="col-md-6 col-sm-12">
        <?php 
foreach ($propertyGroups as $groupId => $properties) {
    ?>

            <?php 
    if (count($properties) > 0) {
        $group = \app\models\PropertyGroup::findById($groupId);
        if (intval($group->hidden_group_title) == 0) {
            echo Html::tag('h2', $group->name);
        }
        $properties = app\models\Property::getForGroupId($groupId);
        foreach ($properties as $prop) {
            $property_values = $model->getPropertyValuesByPropertyId($prop->id);
            echo $prop->handler($form, $model->getAbstractModel(), $property_values, 'frontend_edit_view');
        }
    }
    ?>


        <?php 
}
?>
 public function up()
 {
     mb_internal_encoding(Yii::$app->getModule('core')->internalEncoding);
     $data = (include __DIR__ . DIRECTORY_SEPARATOR . 'demo-data.php');
     $productObject = Object::getForClass(Product::className());
     /** @var PropertyHandler $handler */
     $handler = PropertyHandler::findOne(['handler_class_name' => 'app\\properties\\handlers\\text\\TextProperty']);
     if (!is_null($handler)) {
         $this->textHandlerId = $handler->id;
     }
     $handler = PropertyHandler::findOne(['handler_class_name' => 'app\\properties\\handlers\\select\\SelectProperty']);
     if (!is_null($handler)) {
         $this->selectHandlerId = $handler->id;
     }
     $this->insert(PropertyGroup::tableName(), ['object_id' => $productObject->id, 'name' => 'Общая группа свойств']);
     $commonGroupId = $this->db->lastInsertID;
     $this->insert(Property::tableName(), ['property_group_id' => $commonGroupId, 'name' => 'Производитель', 'key' => 'vendor', 'property_handler_id' => $this->selectHandlerId, 'handler_additional_params' => '{}', 'has_static_values' => 1, 'has_slugs_in_values' => 1]);
     $this->properties['vendor'] = $this->db->lastInsertID;
     $staticProperties = ['Тип крепления бура', 'Макс. энергия удара', 'Количество скоростей работы', 'Питание', 'Тип процессора', 'Тип памяти', 'Частота памяти: 1600 МГц', 'Количество слотов памяти', 'Максимальный размер памяти', 'Размер экрана: 15.6 "', 'Тип экрана', 'Тип видеоадаптера'];
     foreach ($data as $category) {
         $this->insert(Category::tableName(), ['category_group_id' => 1, 'parent_id' => 1, 'name' => $category['name'], 'h1' => $category['name'], 'title' => $category['name'] . ' с доставкой в любой город России и СНГ', 'breadcrumbs_label' => $category['name'], 'slug' => Helper::createSlug($category['name']), 'announce' => $category['content'], 'content' => $category['content']]);
         $categoryId = $this->db->lastInsertID;
         $this->insert(PropertyGroup::tableName(), ['object_id' => $productObject->id, 'name' => $category['name']]);
         $groupId = $this->db->lastInsertID;
         foreach ($category['products'] as $product) {
             // product
             $slug = Helper::createSlug($product['name']);
             if (isset($this->products[$slug])) {
                 $slug = mb_substr($slug, 0, 66) . '-' . uniqid();
             }
             $this->insert(Product::tableName(), ['parent_id' => 0, 'measure_id' => 1, 'currency_id' => 1, 'sku' => $product['id'], 'main_category_id' => $categoryId, 'name' => $product['name'], 'title' => $product['name'], 'breadcrumbs_label' => $product['name'], 'h1' => $product['name'], 'slug' => $slug, 'announce' => Helper::trimPlain($product['description']), 'content' => $product['description'], 'price' => $product['prices']['min'], 'old_price' => $product['prices']['max']]);
             $productId = $this->db->lastInsertID;
             $this->products[$slug] = $productId;
             // categories
             $this->batchInsert('{{%product_category}}', ['category_id', 'object_model_id'], [[1, $productId], [$categoryId, $productId]]);
             // property groups
             $this->batchInsert(ObjectPropertyGroup::tableName(), ['object_id', 'object_model_id', 'property_group_id'], [[$productObject->id, $productId, $commonGroupId], [$productObject->id, $productId, $groupId]]);
             // properties
             if (isset($product['vendor'])) {
                 $this->saveStatic($productId, 'vendor', $product['vendor']);
             }
             foreach ($product['details']['modelDetails'] as $group) {
                 foreach ($group['params'] as $property) {
                     $property['name'] = trim($property['name'], '/ ');
                     if (in_array($property['name'], $staticProperties)) {
                         $key = $this->getKey($property['name']);
                         if (!isset($this->properties[$key])) {
                             $this->insert(Property::tableName(), ['property_group_id' => $groupId, 'name' => $property['name'], 'key' => $key, 'property_handler_id' => $this->selectHandlerId, 'handler_additional_params' => '{}', 'has_static_values' => 1, 'has_slugs_in_values' => 1]);
                             $this->properties[$key] = $this->db->lastInsertID;
                         }
                         $this->saveStatic($productId, $this->getKey($property['name']), str_replace($property['name'] . ': ', '', $property['value']));
                     } else {
                         $this->saveEav($productId, $groupId, $property['name'], str_replace($property['name'] . ': ', '', $property['value']));
                     }
                 }
             }
             // images
             $prodPhotos = [];
             if (isset($product['photos'])) {
                 foreach ($product['photos'] as $photo) {
                     $prodPhotos[] = [$productObject->id, $productId, $photo['name'], $product['name'], $product['name']];
                 }
             }
             if (isset($product['mainPhoto']['name'])) {
                 $prodPhotos[] = [$productObject->id, $productId, $product['mainPhoto']['name'], $product['name'], $product['name']];
             }
             if (count($prodPhotos) > 0) {
                 $this->batchInsert(Image::tableName(), ['object_id', 'object_model_id', 'filename', 'image_alt', 'image_title'], $prodPhotos);
             }
         }
     }
     srand();
     $cdnNumber = rand(1, 2);
     $imgUrl = "http://static-{$cdnNumber}.dotplant.ru/demo-photos.zip";
     $imagesPath = Yii::getAlias('@webroot/files/');
     $imgsFile = $imagesPath . DIRECTORY_SEPARATOR . 'imgs.zip';
     if (file_exists($imgsFile) === false) {
         $fp = fopen($imgsFile, 'w+');
         $ch = curl_init($imgUrl);
         curl_setopt($ch, CURLOPT_TIMEOUT, 600);
         curl_setopt($ch, CURLOPT_FILE, $fp);
         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
         curl_exec($ch);
         curl_close($ch);
         fclose($fp);
     }
     if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
         echo "\n\nWow! You are running windows! Please unzip {$imgsFile} to {$imagesPath} \n\n";
     } else {
         passthru('/usr/bin/env unzip -n "' . $imgsFile . '" -d "' . $imagesPath . '"');
     }
 }
Esempio n. 20
0
 public function getPropertyGroups($force = false, $getByObjectId = false, $createAbstractModel = false)
 {
     $message = "getPropertyGroups " . $this->owner->className() . ':' . $this->owner->id . " force:" . ($force ? 'true' : 'false') . " getByObjectId:" . ($getByObjectId ? 'true' : 'false') . " createAbstractModel:" . ($createAbstractModel ? 'true' : 'false');
     Yii::trace($message, 'properties');
     $cacheKey = $message;
     if ($this->properties === null && $force === false) {
         // try to get from cache
         $data = Yii::$app->cache->get($message);
         if ($data !== false) {
             Yii::trace("Properties from cache", 'properties');
             $this->abstract_model = isset($data['abstract_model']) ? $data['abstract_model'] : [];
             $this->properties = $data['properties'];
             $this->property_key_to_id = $data['property_key_to_id'];
             $this->property_id_to_group_id = $data['property_id_to_group_id'];
         }
     }
     if ($createAbstractModel === true && is_null($this->abstract_model)) {
         // force creating abstract model if it is null and needed
         $force = true;
     }
     if ($this->properties === null || $force === true) {
         $tags = [ActiveRecordHelper::getObjectTag($this->owner->className(), $this->owner->id)];
         $this->properties = [];
         if ($getByObjectId === true) {
             $groups = PropertyGroup::getForObjectId($this->getObject()->id);
         } else {
             $groups = PropertyGroup::getForModel($this->getObject()->id, $this->owner->id);
         }
         $values_for_abstract = [];
         $properties_models = [];
         $rules = [];
         /** @var PropertyGroup $group */
         foreach ($groups as $group) {
             $tags[] = ActiveRecordHelper::getObjectTag(PropertyGroup::className(), $group->id);
             $this->properties[$group->id] = [];
             $props = Property::getForGroupId($group->id);
             foreach ($props as $p) {
                 $values = $this->getPropertyValues($p);
                 $this->properties[$group->id][$p->key] = $values;
                 if ($createAbstractModel === true) {
                     $values_for_abstract[$p->key] = $values;
                 }
                 $properties_models[$p->key] = $p;
                 $this->property_key_to_id[$p->key] = $p->id;
                 if (!isset($this->property_id_to_group_id[$group->id])) {
                     $this->property_id_to_group_id[$group->id] = [$p->key];
                 } else {
                     $this->property_id_to_group_id[$group->id][] = $p->key;
                 }
                 if ($createAbstractModel === true) {
                     $handlerAdditionalParams = Json::decode($p->handler_additional_params);
                     if (isset($handlerAdditionalParams['rules']) && is_array($handlerAdditionalParams['rules'])) {
                         foreach ($handlerAdditionalParams['rules'] as $rule) {
                             if (is_array($rule)) {
                                 $rules[] = ArrayHelper::merge([$p->key], $rule);
                             } else {
                                 $rules[] = [$p->key, $rule];
                             }
                         }
                     }
                 }
             }
         }
         if ($createAbstractModel === true) {
             $this->abstract_model = new AbstractModel([], $this->owner);
             $this->abstract_model->setPropertiesModels($properties_models);
             $this->abstract_model->setAttributes($values_for_abstract);
             $this->abstract_model->setFormName('Properties_' . $this->owner->formName() . '_' . $this->owner->id);
             $this->abstract_model->addRules($rules);
         }
         $res = Yii::$app->cache->set($cacheKey, ['properties' => $this->properties, 'abstract_model' => $this->abstract_model, 'property_id_to_group_id' => $this->property_id_to_group_id, 'property_key_to_id' => $this->property_key_to_id], 86400, new TagDependency(['tags' => $tags]));
         Yii::trace('putting props to cache: ' . ($res ? 'true' : 'false') . ' key:' . $cacheKey, 'properties');
     }
     return $this->properties;
 }
 public function up()
 {
     mb_internal_encoding("UTF-8");
     $tableOptions = $this->db->driverName === 'mysql' ? 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB' : null;
     //        $lang = 'ru-RU';
     //        Yii::$app->language = $lang;
     //        // drop all
     //        $tables = $this->db->createCommand("SHOW TABLES")->queryAll();
     //        $this->db->createCommand("SET foreign_key_checks = 0")->execute();
     //        foreach ($tables as $table) {
     //            $this->dropTable($table['Tables_in_dotplant2_test']);
     //        }
     // create tables
     $this->createTable(ApiService::tableName(), ['service_id' => 'VARCHAR(255) NOT NULL PRIMARY KEY', 'access_token' => 'VARCHAR(255) NOT NULL', 'token_type' => 'VARCHAR(255) NOT NULL ', 'expires_in' => 'INT UNSIGNED NOT NULL ', 'create_ts' => 'INT UNSIGNED NOT NULL '], $tableOptions);
     $this->createTable('{{%session}}', ['id' => 'char(40) NOT NULL PRIMARY KEY', 'expire' => 'INT DEFAULT NULL', 'data' => 'BLOB'], $tableOptions);
     $this->createTable(Image::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'object_id' => 'INT UNSIGNED NOT NULL', 'object_model_id' => 'INT UNSIGNED NOT NULL', 'filename' => 'VARCHAR(255) NOT NULL', 'image_description' => 'VARCHAR(255) NOT NULL', 'sort_order' => 'INT DEFAULT \'0\'', 'KEY `ix-image-object_id-object_model_id` (`object_id`, `object_model_id`)', 'KEY `ix-image-filename` (`filename`)'], $tableOptions);
     $this->createTable(Navigation::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'parent_id' => 'INT UNSIGNED NOT NULL', 'name' => 'VARCHAR(255) NOT NULL', 'url' => 'VARCHAR(255)', 'route' => 'VARCHAR(255)', 'route_params' => 'TEXT DEFAULT NULL', 'advanced_css_class' => 'VARCHAR(255)', 'sort_order' => 'INT DEFAULT \'0\'', 'KEY `ix-navigation-parent_id` (`parent_id`)'], $tableOptions);
     $this->createTable(DynamicContent::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'route' => 'VARCHAR(255) DEFAULT NULL', 'name' => 'VARCHAR(255) DEFAULT NULL', 'content_block_name' => 'VARCHAR(80) DEFAULT \'content\'', 'content' => 'TEXT DEFAULT NULL', 'title' => 'VARCHAR(255)', 'h1' => 'VARCHAR(255) DEFAULT NULL', 'meta_description' => 'VARCHAR(255) DEFAULT NULL', 'apply_if_last_category_id' => 'INT UNSIGNED DEFAULT NULL', 'apply_if_params' => 'TEXT DEFAULT NULL', 'object_id' => 'INT UNSIGNED DEFAULT NULL', 'KEY `object_route` (`object_id`,`route`(80))'], $tableOptions);
     $this->createTable(Object::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'name' => 'VARCHAR(255) NOT NULL', 'object_class' => 'VARCHAR(255) NOT NULL', 'object_table_name' => 'VARCHAR(255) NOT NULL', 'column_properties_table_name' => 'VARCHAR(255) NOT NULL', 'eav_table_name' => 'VARCHAR(255) NOT NULL', 'categories_table_name' => 'VARCHAR(255) NOT NULL', 'link_slug_category' => 'VARCHAR(255) NOT NULL', 'link_slug_static_value' => 'VARCHAR(255) NOT NULL', 'object_slug_attribute' => 'VARCHAR(255) NOT NULL', 'KEY `ix-object-object_class` (`object_class`)'], $tableOptions);
     $this->createTable(ObjectPropertyGroup::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'object_id' => 'INT UNSIGNED NOT NULL', 'object_model_id' => 'INT UNSIGNED NOT NULL', 'property_group_id' => 'INT UNSIGNED NOT NULL', 'KEY `ix-object_property_group-object_id-object_model_id` (`object_id`,`object_model_id`)'], $tableOptions);
     $this->createTable(ObjectStaticValues::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'object_id' => 'INT UNSIGNED NOT NULL', 'object_model_id' => 'INT UNSIGNED NOT NULL', 'property_static_value_id' => 'INT UNSIGNED NOT NULL', 'KEY `ix-object-static-values-object_id-object_model_id` (`object_id`, `object_model_id`)'], $tableOptions);
     $this->createTable(PropertyGroup::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'object_id' => 'INT UNSIGNED NOT NULL', 'name' => 'VARCHAR(255) NOT NULL', 'sort_order' => 'INT DEFAULT \'0\'', 'is_internal' => 'TINYINT DEFAULT \'0\'', 'hidden_group_title' => 'TINYINT DEFAULT \'0\'', 'KEY `ix-property_group-object_id` (`object_id`)'], $tableOptions);
     $this->createTable(PropertyHandler::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'name' => 'VARCHAR(255) NOT NULL', 'frontend_render_view' => 'VARCHAR(255) NOT NULL', 'frontend_edit_view' => 'VARCHAR(255) NOT NULL', 'backend_render_view' => 'VARCHAR(255) NOT NULL', 'backend_edit_view' => 'VARCHAR(255) NOT NULL', 'handler_class_name' => 'VARCHAR(255) NOT NULL'], $tableOptions);
     $this->createTable(PropertyStaticValues::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'property_id' => 'INT UNSIGNED NOT NULL', 'name' => 'VARCHAR(255) NOT NULL', 'value' => 'VARCHAR(255) NOT NULL', 'slug' => 'VARCHAR(255) NOT NULL', 'sort_order' => 'INT DEFAULT \'0\'', 'title_append' => 'VARCHAR(255) DEFAULT NULL', 'dont_filter' => 'TINYINT(1) NOT NULL DEFAULT \'0\'', 'KEY `ix-property_static_values-property_id` (`property_id`)'], $tableOptions);
     $this->createTable('{{%product_category_full_slug}}', ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'category_id' => 'INT UNSIGNED NOT NULL', 'full_slug_id' => 'INT UNSIGNED NOT NULL', 'KEY `category_id` (`category_id`)'], $tableOptions);
     $this->createTable('{{%product_static_value_full_slug}}', ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'full_slug_id' => 'INT UNSIGNED NOT NULL', 'property_static_value_id' => 'INT UNSIGNED NOT NULL', 'KEY `property_static_value_id` (`property_static_value_id`)'], $tableOptions);
     $this->createTable('{{%product_eav}}', ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'object_model_id' => 'INTEGER UNSIGNED NOT NULL', 'property_group_id' => 'INT UNSIGNED NOT NULL', 'key' => 'VARCHAR(255) NOT NULL', 'value' => 'TEXT DEFAULT NULL', 'sort_order' => 'INTEGER DEFAULT \'0\'', 'KEY  `object_model_id` (`object_model_id`)'], $tableOptions);
     $this->createTable(Route::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'route' => 'VARCHAR(255) NOT NULL', 'url_template' => 'TEXT', 'object_id' => 'INT UNSIGNED DEFAULT NULL', 'name' => 'VARCHAR(255)'], $tableOptions);
     $this->createTable(Property::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'property_group_id' => 'INT UNSIGNED NOT NULL', 'name' => 'VARCHAR(255) NOT NULL', 'key' => 'VARCHAR(20) DEFAULT \'\'', 'value_type' => 'ENUM(\'STRING\',\'NUMBER\') DEFAULT \'STRING\'', 'property_handler_id' => 'INT UNSIGNED NOT NULL', 'has_static_values' => 'TINYINT DEFAULT \'0\'', 'has_slugs_in_values' => 'TINYINT DEFAULT \'0\'', 'is_eav' => 'TINYINT DEFAULT \'0\'', 'is_column_type_stored' => 'TINYINT DEFAULT \'0\'', 'multiple' => 'TINYINT DEFAULT \'0\'', 'sort_order' => 'INT DEFAULT \'0\'', 'handler_additional_params' => 'TEXT NOT NULL', 'display_only_on_depended_property_selected' => 'TINYINT DEFAULT \'0\'', 'depends_on_property_id' => 'INT DEFAULT \'0\'', 'depended_property_values' => 'TEXT DEFAULT NULL', 'depends_on_category_group_id' => 'INT DEFAULT \'0\'', 'hide_other_values_if_selected' => 'TINYINT DEFAULT \'0\'', 'dont_filter' => 'TINYINT(1) NOT NULL DEFAULT \'0\'', 'KEY `ix-property-property_group_id` (`property_group_id`)'], $tableOptions);
     $this->createTable(Product::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'main_category_id' => 'INT UNSIGNED NOT NULL', 'parent_id' => 'INT UNSIGNED DEFAULT \'0\'', 'option_generate' => 'TEXT DEFAULT NULL', 'name' => 'VARCHAR(255) NOT NULL', 'title' => 'VARCHAR(255) DEFAULT NULL', 'h1' => 'VARCHAR(255) DEFAULT NULL', 'meta_description' => 'VARCHAR(255) DEFAULT NULL', 'breadcrumbs_label' => 'VARCHAR(255) DEFAULT NULL', 'slug' => 'VARCHAR(80) DEFAULT \'\'', 'slug_compiled' => 'VARCHAR(180) DEFAULT \'\'', 'slug_absolute' => 'TINYINT DEFAULT \'0\'', 'content' => 'TEXT DEFAULT NULL', 'announce' => 'TEXT DEFAULT NULL', 'sort_order' => 'INT DEFAULT \'0\'', 'active' => 'TINYINT DEFAULT \'1\'', 'price' => 'FLOAT UNSIGNED DEFAULT \'0\'', 'old_price' => 'FLOAT UNSIGNED DEFAULT \'0\'', 'sku' => 'VARCHAR(70) NOT NULL DEFAULT \'\'', 'unlimited_count' => 'TINYINT NOT NULL DEFAULT \'1\'', 'currency_id' => 'INT UNSIGNED NOT NULL DEFAULT \'1\'', 'measure_id' => 'INT UNSIGNED NOT NULL', 'KEY `ix-product-active-slug` (`active`, `slug`)', 'KEY `ix-product-parent_id` (`parent_id`)', 'KEY `sku` (`sku`)', 'KEY `parent_active` (`parent_id`,`active`)'], $tableOptions);
     $this->createTable('{{%product_property}}', ['object_model_id' => 'INT UNSIGNED NOT NULL PRIMARY KEY'], $tableOptions);
     $this->createTable(Layout::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'name' => 'VARCHAR(255) NOT NULL', 'layout' => 'VARCHAR(255) NOT NULL'], $tableOptions);
     $this->createTable(View::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'name' => 'VARCHAR(255) NOT NULL', 'view' => 'TEXT NOT NULL', 'category' => 'VARCHAR(255) DEFAULT NULL', 'internal_name' => 'VARCHAR(255) DEFAULT NULL', 'KEY `ix-view-internal_name-category` (`internal_name`, `category`)'], $tableOptions);
     $this->createTable(ViewObject::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'object_id' => 'INT UNSIGNED NOT NULL', 'object_model_id' => 'INT UNSIGNED NOT NULL', 'view_id' => 'INT UNSIGNED NOT NULL', 'UNIQUE KEY `uq-view_object-object_id-object_model_id` (`object_id`, `object_model_id`)'], $tableOptions);
     $this->createTable(Page::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'parent_id' => 'INT UNSIGNED NOT NULL', 'slug' => 'VARCHAR(80) NOT NULL', 'slug_compiled' => 'VARCHAR(180) NOT NULL DEFAULT \'\'', 'slug_absolute' => 'TINYINT(1) UNSIGNED DEFAULT \'0\'', 'content' => 'LONGTEXT', 'show_type' => "ENUM('show','list') DEFAULT 'show'", 'published' => 'TINYINT(1) UNSIGNED DEFAULT \'1\'', 'searchable' => 'TINYINT(1) UNSIGNED DEFAULT \'1\'', 'robots' => 'TINYINT(3) UNSIGNED DEFAULT \'3\'', 'name' => 'VARCHAR(255) DEFAULT NULL', 'title' => 'TEXT NOT NULL', 'h1' => 'TEXT DEFAULT NULL', 'meta_description' => 'TEXT DEFAULT NULL', 'breadcrumbs_label' => 'TEXT DEFAULT NULL', 'announce' => 'TEXT DEFAULT NULL', 'sort_order' => 'INT DEFAULT \'0\'', 'date_added' => 'TIMESTAMP DEFAULT CURRENT_TIMESTAMP', 'date_modified' => 'TIMESTAMP NULL', 'subdomain' => 'VARCHAR(255) DEFAULT NULL', 'KEY `ix-page-slug_compiled-published` (`slug_compiled`, `published`)', 'KEY `ix-page-parent_id` (`parent_id`)'], $tableOptions);
     $this->createTable('{{%page_property}}', ['object_model_id' => 'INT UNSIGNED NOT NULL PRIMARY KEY'], $tableOptions);
     $this->createTable('{{%page_category}}', ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'category_id' => 'INT UNSIGNED NOT NULL', 'object_model_id' => 'INT UNSIGNED NOT NULL'], $tableOptions);
     $this->createTable('{{%page_eav}}', ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'object_model_id' => 'INT UNSIGNED NOT NULL', 'property_group_id' => 'INT UNSIGNED NOT NULL', 'key' => 'VARCHAR(255) NOT NULL', 'value' => 'TEXT DEFAULT NULL', 'sort_order' => 'INTEGER DEFAULT \'0\'', 'KEY `object_model_id` (`object_model_id`)'], $tableOptions);
     $this->createTable(CategoryGroup::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'name' => 'VARCHAR(255) NOT NULL'], $tableOptions);
     $this->createTable(Category::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'category_group_id' => 'INT UNSIGNED NOT NULL', 'parent_id' => 'INT UNSIGNED NOT NULL', 'name' => 'VARCHAR(255) NOT NULL', 'title' => 'VARCHAR(255) NOT NULL', 'h1' => 'VARCHAR(255) NOT NULL', 'meta_description' => 'VARCHAR(255) DEFAULT NULL', 'breadcrumbs_label' => 'VARCHAR(255) DEFAULT NULL', 'slug' => 'VARCHAR(80) DEFAULT \'\'', 'slug_compiled' => 'VARCHAR(180) DEFAULT \'\'', 'slug_absolute' => 'TINYINT DEFAULT \'0\'', 'content' => 'TEXT DEFAULT NULL', 'announce' => 'TEXT DEFAULT NULL', 'sort_order' => 'INT DEFAULT \'0\'', 'title_append' => 'VARCHAR(255) DEFAULT NULL', 'active' => 'TINYINT UNSIGNED DEFAULT \'1\'', 'KEY `ix-category-category_group_id` (`category_group_id`, `parent_id`)', 'KEY `ix-category-parent_id` (`parent_id`)'], $tableOptions);
     $this->createTable('{{%category_eav}}', ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'object_model_id' => 'INT UNSIGNED NOT NULL', 'property_group_id' => 'INT UNSIGNED NOT NULL', 'key' => 'VARCHAR(255) NOT NULL', 'value' => 'TEXT DEFAULT NULL', 'sort_order' => 'INT DEFAULT \'0\'', 'KEY `object_model_id` (`object_model_id`)'], $tableOptions);
     $this->createTable('{{%property_category}}', ['object_model_id' => 'INT UNSIGNED NOT NULL PRIMARY KEY'], $tableOptions);
     $this->createTable('{{%product_category}}', ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'category_id' => 'INT UNSIGNED NOT NULL', 'object_model_id' => 'INT UNSIGNED NOT NULL', 'sort_order' => 'INT DEFAULT \'0\'', 'KEY `cat_omid` (`category_id`,`object_model_id`)'], $tableOptions);
     $this->createTable(CategoryGroupRouteTemplates::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'category_group_id' => 'int(11) unsigned NOT NULL', 'route_id' => 'INT UNSIGNED NOT NULL', 'template_json' => 'TEXT NOT NULL', 'KEY `ix-category-group-route-templates-category_group_id-route_id` (`category_group_id`, `route_id`)'], $tableOptions);
     $this->createTable(SubscribeEmail::tableName(), ['id' => 'INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'email' => 'VARCHAR(100) DEFAULT NULL', 'name' => 'VARCHAR(50) DEFAULT NULL', 'is_active' => 'TINYINT DEFAULT \'0\'', 'last_notify' => 'INTEGER DEFAULT \'0\''], $tableOptions);
     $this->createTable(Order::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'user_id' => 'INT UNSIGNED NOT NULL', 'manager_id' => 'INT UNSIGNED DEFAULT \'0\'', 'start_date' => 'TIMESTAMP DEFAULT CURRENT_TIMESTAMP', 'update_date' => 'TIMESTAMP NULL', 'end_date' => "TIMESTAMP NULL", 'cart_forming_time' => 'INT DEFAULT \'0\'', 'order_stage_id' => 'INT UNSIGNED NOT NULL', 'payment_type_id' => 'INT UNSIGNED DEFAULT \'0\'', 'assigned_id' => 'INT UNSIGNED DEFAULT NULL', 'tax_id' => 'INT UNSIGNED DEFAULT NULL', 'external_id' => 'VARCHAR(38) DEFAULT NULL', 'items_count' => 'FLOAT UNSIGNED DEFAULT NULL', 'total_price' => 'FLOAT DEFAULT \'0\'', 'total_payed' => 'FLOAT DEFAULT \'0\'', 'hash' => 'CHAR(32) NOT NULL', 'is_deleted' => 'TINYINT UNSIGNED DEFAULT 0', 'temporary' => 'TINYINT(1) UNSIGNED NOT NULL DEFAULT 1', 'show_price_changed_notification' => 'TINYINT(1) UNSIGNED NOT NULL DEFAULT 0', 'customer_id' => 'INT UNSIGNED NOT NULL DEFAULT 0', 'contragent_id' => 'INT UNSIGNED NOT NULL DEFAULT 0', 'in_cart' => Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 0', 'KEY `ix-order-user_id` (`user_id`)', 'KEY `ix-order-manager_id` (`manager_id`)', 'UNIQUE KEY `uq-order-hash` (`hash`)'], $tableOptions);
     // @todo Set all float fields as unsigned
     $this->createTable(OrderItem::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'parent_id' => 'INT UNSIGNED NOT NULL DEFAULT 0', 'order_id' => 'INT UNSIGNED DEFAULT \'0\'', 'product_id' => 'INT UNSIGNED NOT NULL', 'custom_name' => 'VARCHAR(255)', 'quantity' => 'FLOAT NOT NULL DEFAULT \'1\'', 'price_per_pcs' => 'FLOAT NOT NULL DEFAULT \'0\'', 'total_price_without_discount' => 'FLOAT NOT NULL DEFAULT \'0\'', 'lock_product_price' => 'TINYINT(1) UNSIGNED NOT NULL DEFAULT 0', 'discount_amount' => 'FLOAT NOT NULL DEFAULT \'0\'', 'total_price' => 'FLOAT NOT NULL DEFAULT \'0\'', 'KEY `ix-order_item-order_id` (`order_id`)'], $tableOptions);
     $this->createTable(OrderTransaction::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'order_id' => 'INT UNSIGNED NOT NULL', 'payment_type_id' => 'INT UNSIGNED NOT NULL', 'start_date' => 'TIMESTAMP DEFAULT CURRENT_TIMESTAMP', 'end_date' => 'TIMESTAMP NULL', 'status' => 'TINYINT UNSIGNED NOT NULL', 'total_sum' => 'DECIMAL(10, 2) NOT NULL', 'params' => 'TEXT', 'result_data' => 'TEXT', 'KEY `ix-order_transaction-order_id` (`order_id`)'], $tableOptions);
     $this->createTable(OrderChat::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'order_id' => 'INTEGER UNSIGNED NOT NULL', 'user_id' => 'INTEGER UNSIGNED NOT NULL', 'date' => 'TIMESTAMP DEFAULT CURRENT_TIMESTAMP', 'message' => 'TEXT DEFAULT NULL', 'KEY `ix-order_chat-order_id` (`order_id`)'], $tableOptions);
     $this->createTable(ShippingOption::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'name' => 'VARCHAR(255) NOT NULL', 'description' => 'VARCHAR(255) NOT NULL', 'price_from' => 'FLOAT DEFAULT 0', 'price_to' => 'FLOAT DEFAULT 0', 'cost' => 'FLOAT DEFAULT 0', 'sort' => 'INT DEFAULT \'0\'', 'active' => 'TINYINT DEFAULT \'0\'', 'KEY `ix-shipping_option-active` (`active`)'], $tableOptions);
     $this->createTable(PaymentType::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'name' => 'VARCHAR(255) NOT NULL', 'class' => 'VARCHAR(255) NOT NULL', 'params' => 'TEXT DEFAULT NULL', 'logo' => 'VARCHAR(255) DEFAULT NULL', 'commission' => 'FLOAT DEFAULT \'0\'', 'active' => 'TINYINT DEFAULT \'0\'', 'payment_available' => 'TINYINT DEFAULT \'1\'', 'sort' => 'TINYINT DEFAULT \'1\'', 'KEY `ix-payment_type-active` (`active`)'], $tableOptions);
     $this->createTable('{{%order_property}}', ['object_model_id' => 'INTEGER UNSIGNED NOT NULL PRIMARY KEY'], $tableOptions);
     $this->createTable('{{%order_eav}}', ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'object_model_id' => 'INTEGER UNSIGNED NOT NULL', 'property_group_id' => 'INT UNSIGNED NOT NULL', 'key' => 'VARCHAR(255) NOT NULL', 'value' => 'TEXT DEFAULT NULL', 'sort_order' => 'INTEGER DEFAULT \'0\'', 'KEY `object_model_id` (`object_model_id`)'], $tableOptions);
     $this->createTable('{{%order_category}}', ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'category_id' => 'INTEGER UNSIGNED NOT NULL', 'object_model_id' => 'INTEGER UNSIGNED NOT NULL'], $tableOptions);
     $this->createTable(Form::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'name' => 'VARCHAR(255) NOT NULL', 'form_view' => 'VARCHAR(255) DEFAULT NULL', 'form_success_view' => 'VARCHAR(255) DEFAULT NULL', 'email_notification_addresses' => 'TEXT NOT NULL', 'email_notification_view' => 'VARCHAR(255) DEFAULT NULL', 'form_open_analytics_action_id' => 'INT UNSIGNED DEFAULT NULL', 'form_submit_analytics_action_id' => 'INT UNSIGNED DEFAULT NULL'], $tableOptions);
     $this->createTable('{{%form_eav}}', ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'object_model_id' => 'INT UNSIGNED NOT NULL', 'property_group_id' => 'INT UNSIGNED NOT NULL', 'key' => 'VARCHAR(255) NOT NULL', 'value' => 'TEXT', 'sort_order' => 'INTEGER DEFAULT \'0\'', 'KEY  `object_model_id` (`object_model_id`)'], $tableOptions);
     $this->createTable('{{%form_property}}', ['object_model_id' => 'INT UNSIGNED NOT NULL PRIMARY KEY'], $tableOptions);
     $this->createTable(Submission::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'form_id' => 'INT UNSIGNED NOT NULL', 'date_received' => 'DATETIME DEFAULT NULL', 'ip' => 'VARCHAR(255) DEFAULT NULL', 'user_agent' => 'VARCHAR(255) DEFAULT NULL', 'piwik_visitor_id' => 'VARCHAR(255) DEFAULT NULL', 'additional_information' => 'LONGTEXT', 'date_viewed' => 'DATETIME DEFAULT NULL', 'date_processed' => 'DATETIME DEFAULT NULL', 'processed_by_user_id' => 'INT UNSIGNED DEFAULT NULL', 'processed' => 'TINYINT(1) DEFAULT \'0\'', 'internal_comment' => 'TEXT DEFAULT NULL', 'submission_referrer' => 'VARCHAR(255) DEFAULT NULL', 'visitor_referrer' => 'VARCHAR(255) DEFAULT NULL', 'visitor_landing' => 'VARCHAR(255) DEFAULT NULL', 'visit_start_date' => 'DATETIME DEFAULT NULL', 'form_fill_time' => 'INT DEFAULT NULL', 'spam' => 'TINYINT(1) UNSIGNED DEFAULT 0', 'is_deleted' => 'TINYINT UNSIGNED DEFAULT \'0\'', 'KEY `submission-form_id` (`form_id`)'], $tableOptions);
     $this->createTable('{{%submission_property}}', ['object_model_id' => 'INT UNSIGNED NOT NULL PRIMARY KEY'], $tableOptions);
     $this->createTable('{{%submission_category}}', ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'category_id' => 'INT UNSIGNED NOT NULL', 'object_model_id' => 'INT UNSIGNED NOT NULL'], $tableOptions);
     $this->createTable('{{%submission_eav}}', ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'object_model_id' => 'INT UNSIGNED NOT NULL', 'property_group_id' => 'INT UNSIGNED NOT NULL', 'key' => 'VARCHAR(255) NOT NULL', 'value' => 'TEXT DEFAULT NULL', 'sort_order' => 'INTEGER DEFAULT \'0\'', 'KEY  `object_model_id` (`object_model_id`)'], $tableOptions);
     $this->createTable(Notification::tableName(), ['id' => 'BIGINT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'user_id' => 'INTEGER UNSIGNED NOT NULL', 'date' => 'TIMESTAMP DEFAULT CURRENT_TIMESTAMP', 'type' => 'ENUM(\'default\', \'primary\', \'success\', \'info\', \'warning\', \'danger\') DEFAULT \'default\'', 'label' => 'VARCHAR(255) NOT NULL', 'message' => 'TEXT NOT NULL', 'viewed' => 'TINYINT UNSIGNED DEFAULT \'0\'', 'KEY `user_id` (`user_id`)'], $tableOptions);
     $this->createTable(Review::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'object_id' => 'INT UNSIGNED DEFAULT \'0\'', 'object_model_id' => 'INT UNSIGNED NOT NULL', 'author_email' => 'VARCHAR(255) DEFAULT NULL', 'review_text' => 'TEXT DEFAULT NULL', 'status' => 'enum(\'NEW\',\'APPROVED\',\'NOT APPROVED\') DEFAULT \'NEW\'', 'rating_id' => 'CHAR(32) CHARACTER SET utf8 DEFAULT NULL', 'submission_id' => 'int unsigned NOT NULL', 'KEY `ix-review-object_id-object_model_id-status` (`object_id`, `object_model_id`, `status`)'], $tableOptions);
     $this->createTable(ErrorLog::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'url_id' => 'INT UNSIGNED NOT NULL', 'http_code' => 'SMALLINT', 'timestamp' => 'TIMESTAMP DEFAULT CURRENT_TIMESTAMP', 'info' => 'TEXT DEFAULT NULL', 'server_vars' => 'TEXT DEFAULT NULL', 'request_vars' => 'TEXT DEFAULT NULL'], $tableOptions);
     $this->createTable(ErrorUrl::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'url' => 'TEXT DEFAULT NULL', 'immediate_notify_count' => 'INT UNSIGNED DEFAULT \'0\''], $tableOptions);
     $this->createTable('{{%auth_rule}}', ['name' => 'VARCHAR(64) NOT NULL PRIMARY KEY', 'data' => 'TEXT', 'created_at' => 'INT DEFAULT NULL', 'updated_at' => 'INT DEFAULT NULL'], $tableOptions);
     $this->createTable('{{%auth_item}}', ['name' => 'VARCHAR(64) NOT NULL PRIMARY KEY', 'type' => 'INT NOT NULL', 'description' => 'TEXT', 'rule_name' => 'VARCHAR(64)', 'data' => 'TEXT', 'created_at' => 'INT DEFAULT NULL', 'updated_at' => 'INT DEFAULT NULL', 'KEY `rule_name` (`rule_name`)', 'KEY `type` (`type`)', 'CONSTRAINT `auth_item_ibfk_1` FOREIGN KEY (`rule_name`)
                 REFERENCES {{%auth_rule}} (`name`) ON DELETE SET NULL ON UPDATE CASCADE'], $tableOptions);
     $this->createTable('{{%auth_item_child}}', ['parent' => 'VARCHAR(64) NOT NULL', 'child' => 'VARCHAR(64) NOT NULL', 'PRIMARY KEY (`parent`, `child`)', 'KEY `child` (`child`)', 'CONSTRAINT `auth_item_child_ibfk_1` FOREIGN KEY (`parent`)
                 REFERENCES {{%auth_item}} (`name`) ON DELETE CASCADE ON UPDATE CASCADE', 'CONSTRAINT `auth_item_child_ibfk_2` FOREIGN KEY (`child`)
                 REFERENCES {{%auth_item}} (`name`) ON DELETE CASCADE ON UPDATE CASCADE'], $tableOptions);
     $this->createTable('{{%auth_assignment}}', ['item_name' => 'VARCHAR(64) NOT NULL', 'user_id' => 'VARCHAR(64) NOT NULL', 'created_at' => 'INT DEFAULT NULL', 'updated_at' => 'INT DEFAULT NULL', 'rule_name' => 'VARCHAR(64) DEFAULT NULL', 'data' => 'TEXT', 'PRIMARY KEY (`item_name`, `user_id`)', 'KEY `rule_name` (`rule_name`)', 'CONSTRAINT `auth_assignment_ibfk_1` FOREIGN KEY (`item_name`)
                 REFERENCES {{%auth_item}} (`name`) ON DELETE CASCADE ON UPDATE CASCADE', 'CONSTRAINT `auth_assignment_ibfk_2` FOREIGN KEY (`rule_name`)
                 REFERENCES {{%auth_rule}} (`name`) ON DELETE SET NULL ON UPDATE CASCADE'], $tableOptions);
     $this->createTable(User::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'username' => 'VARCHAR(255) NOT NULL', 'auth_key' => 'varbinary(32) NOT NULL', 'password_hash' => 'VARCHAR(255) NOT NULL', 'password_reset_token' => 'varbinary(32)', 'email' => 'VARCHAR(255) NOT NULL', 'status' => 'TINYINT UNSIGNED DEFAULT 10', 'create_time' => 'INT NOT NULL', 'update_time' => 'INT NOT NULL', 'first_name' => 'VARCHAR(255)', 'last_name' => 'VARCHAR(255)', 'username_is_temporary' => 'TINYINT(1) NOT NULL DEFAULT \'0\'', 'UNIQUE KEY `uq-user-username` (`username`)'], $tableOptions);
     $this->createTable(UserService::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'user_id' => 'INT UNSIGNED NOT NULL', 'service_type' => 'VARCHAR(255) NOT NULL', 'service_id' => 'VARCHAR(255) NOT NULL', 'KEY `ix-user_service-user_id` (`user_id`)', 'UNIQUE KEY `uq-user-service-service_type-service_id` (`service_type`, `service_id`)'], $tableOptions);
     $this->createTable('{{%user_property}}', ['object_model_id' => 'INTEGER UNSIGNED NOT NULL PRIMARY KEY'], $tableOptions);
     $this->createTable('{{%user_eav}}', ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'object_model_id' => 'INTEGER UNSIGNED NOT NULL', 'property_group_id' => 'INT UNSIGNED NOT NULL', 'key' => 'VARCHAR(255) NOT NULL', 'value' => 'TEXT DEFAULT NULL', 'sort_order' => 'INTEGER DEFAULT \'0\'', 'KEY `object_model_id` (`object_model_id`)'], $tableOptions);
     $this->createTable('{{%user_category}}', ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'category_id' => 'INTEGER UNSIGNED NOT NULL', 'object_model_id' => 'INTEGER UNSIGNED NOT NULL'], $tableOptions);
     $this->createTable(BackendMenu::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'parent_id' => 'INT UNSIGNED DEFAULT \'0\'', 'name' => 'VARCHAR(255) NOT NULL', 'route' => 'VARCHAR(255) NOT NULL', 'icon' => 'VARCHAR(255) DEFAULT NULL', 'sort_order' => 'INT UNSIGNED DEFAULT \'0\'', 'added_by_ext' => 'VARCHAR(255) DEFAULT NULL', 'rbac_check' => 'VARCHAR(64) DEFAULT NULL', 'css_class' => 'VARCHAR(255) DEFAULT NULL', 'translation_category' => 'VARCHAR(120) NOT NULL DEFAULT \'app\'', 'KEY `ix-backendmenu-parent_id` (`parent_id`)'], $tableOptions);
     $this->createTable('{{%category_property}}', ['object_model_id' => 'INT UNSIGNED NOT NULL PRIMARY KEY'], $tableOptions);
     $this->createTable('{{%data_import}}', ['user_id' => Schema::TYPE_INTEGER . ' unsigned NOT NULL', 'object_id' => Schema::TYPE_INTEGER . ' unsigned NOT NULL', 'filename' => Schema::TYPE_STRING . ' DEFAULT NULL', 'status' => 'enum(\'complete\',\'failed\',\'process\') NOT NULL DEFAULT \'process\'', 'update_time' => Schema::TYPE_INTEGER . ' unsigned NOT NULL', 'PRIMARY KEY (`user_id`,`object_id`)'], $tableOptions);
     $this->createTable(PrefilteredPages::tableName(), ['id' => Schema::TYPE_PK, 'slug' => Schema::TYPE_STRING, 'active' => Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 1', 'last_category_id' => 'INT UNSIGNED NOT NULL DEFAULT 0', 'params' => 'TEXT', 'title' => Schema::TYPE_STRING . ' NOT NULL DEFAULT \'\'', 'announce' => 'TEXT', 'content' => 'TEXT', 'h1' => Schema::TYPE_STRING . ' NOT NULL DEFAULT \'\'', 'meta_description' => Schema::TYPE_STRING . ' NOT NULL DEFAULT \'\'', 'breadcrumbs_label' => Schema::TYPE_STRING . ' NOT NULL DEFAULT \'\'', 'view_id' => Schema::TYPE_INTEGER . ' NOT NULL DEFAULT 0'], $tableOptions);
     $this->createTable(Task::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'action' => 'VARCHAR(255) NOT NULL', 'type' => " enum('EVENT','REPEAT') NOT NULL DEFAULT 'EVENT'", 'initiator' => 'INT UNSIGNED UNSIGNED NOT NULL', 'name' => 'VARCHAR(255) NOT NULL', 'description' => 'TEXT DEFAULT NULL', 'params' => 'TEXT DEFAULT NULL', 'init_event' => 'VARCHAR(255) DEFAULT NULL', 'cron_expression' => 'VARCHAR(255) DEFAULT NULL', 'status' => " enum('ACTIVE','STOPPED','RUNNING','FAILED','COMPLETED', 'PROCESS') NOT NULL DEFAULT 'ACTIVE'", 'ts' => 'TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP', 'fail_counter' => 'TINYINT UNSIGNED NOT NULL DEFAULT\'0\'', 'options' => 'TEXT', 'KEY `name` (`name`)'], $tableOptions);
     $this->createTable(NotifyMessage::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'task_id' => 'INT UNSIGNED NOT NULL', 'result_status' => 'enum(\'SUCCESS\',\'FAULT\') NOT NULL DEFAULT \'SUCCESS\'', 'result' => 'TEXT DEFAULT NULL', 'ts' => 'TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP'], $tableOptions);
     $this->createTable('{{%data_export}}', ['user_id' => Schema::TYPE_INTEGER . ' unsigned NOT NULL', 'object_id' => Schema::TYPE_INTEGER . ' unsigned NOT NULL', 'filename' => Schema::TYPE_STRING . ' DEFAULT NULL', 'status' => 'enum(\'complete\',\'failed\',\'process\') NOT NULL DEFAULT \'process\'', 'update_time' => Schema::TYPE_INTEGER . ' unsigned NOT NULL', 'PRIMARY KEY (`user_id`,`object_id`)'], $tableOptions);
     $this->createTable(ProductListingSort::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'name' => 'VARCHAR(255) NOT NULL', 'sort_field' => 'VARCHAR(255) NOT NULL', 'asc_desc' => 'ENUM(\'asc\',\'desc\') NOT NULL DEFAULT \'asc\'', 'enabled' => Schema::TYPE_SMALLINT . ' NOT NULL DEFAULT 1', 'sort_order' => 'INT UNSIGNED DEFAULT 0'], $tableOptions);
     $this->createTable(SliderHandler::tableName(), ['id' => Schema::TYPE_PK, 'name' => 'VARCHAR(255) NOT NULL DEFAULT \'\'', 'slider_widget' => 'VARCHAR(255) NOT NULL DEFAULT \'\'', 'slider_edit_view_file' => 'VARCHAR(255) NOT NULL DEFAULT \'\'', 'edit_model' => 'VARCHAR(255) NOT NULL DEFAULT \'\''], $tableOptions);
     $this->createTable(Slider::tableName(), ['id' => Schema::TYPE_PK, 'name' => 'VARCHAR(255) NOT NULL DEFAULT \'\'', 'slider_handler_id' => 'INT UNSIGNED DEFAULT 0', 'image_width' => 'INT UNSIGNED DEFAULT 0', 'image_height' => 'INT UNSIGNED DEFAULT 0', 'resize_big_images' => 'TINYINT(1) NOT NULL DEFAULT 1', 'resize_small_images' => 'TINYINT(1) NOT NULL DEFAULT 0', 'css_class' => 'VARCHAR(255) NOT NULL DEFAULT \'\'', 'params' => 'LONGTEXT NULL', 'custom_slider_view_file' => 'VARCHAR(255) NOT NULL DEFAULT \'\'', 'custom_slide_view_file' => 'VARCHAR(255) NOT NULL DEFAULT \'\''], $tableOptions);
     $this->createTable(Slide::tableName(), ['id' => Schema::TYPE_PK, 'slider_id' => 'INT UNSIGNED DEFAULT 0', 'sort_order' => 'INT UNSIGNED DEFAULT 0', 'image' => 'VARCHAR(255) NOT NULL DEFAULT \'\'', 'link' => 'VARCHAR(255) NOT NULL DEFAULT \'\'', 'custom_view_file' => 'VARCHAR(255) NOT NULL DEFAULT \'\'', 'css_class' => 'VARCHAR(255) NOT NULL DEFAULT \'\'', 'active' => 'TINYINT(1) UNSIGNED NOT NULL DEFAULT 1'], $tableOptions);
     $this->createTable(RelatedProduct::tableName(), ['product_id' => 'INT UNSIGNED NOT NULL', 'related_product_id' => 'INT UNSIGNED NOT NULL', 'PRIMARY KEY (`product_id`, `related_product_id`)'], $tableOptions);
     $this->createTable('{{%dynagrid}}', ['id' => Schema::TYPE_STRING . ' DEFAULT \'\' PRIMARY KEY', 'filter_id' => Schema::TYPE_STRING, 'sort_id' => Schema::TYPE_STRING, 'data' => Schema::TYPE_TEXT]);
     $this->createTable('{{%dynagrid_dtl}}', ['id' => Schema::TYPE_STRING . ' DEFAULT \'\' PRIMARY KEY', 'category' => Schema::TYPE_STRING, 'name' => Schema::TYPE_STRING, 'data' => Schema::TYPE_TEXT, 'dynagrid_id' => Schema::TYPE_STRING, 'UNIQUE `uniq_dtl` (`name`, `category`, `dynagrid_id`)']);
     $this->createTable(CurrencyRateProvider::tableName(), ['id' => Schema::TYPE_PK, 'name' => Schema::TYPE_STRING, 'class_name' => Schema::TYPE_STRING, 'params' => Schema::TYPE_TEXT], $tableOptions);
     $this->createTable(Currency::tableName(), ['id' => Schema::TYPE_PK, 'name' => Schema::TYPE_STRING, 'iso_code' => Schema::TYPE_STRING, 'is_main' => Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 0', 'convert_nominal' => Schema::TYPE_FLOAT . ' NOT NULL DEFAULT 1', 'convert_rate' => Schema::TYPE_FLOAT . ' NOT NULL DEFAULT 1', 'sort_order' => Schema::TYPE_INTEGER . ' NOT NULL DEFAULT 0', 'intl_formatting' => Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 1', 'min_fraction_digits' => Schema::TYPE_INTEGER . ' NOT NULL DEFAULT 0', 'max_fraction_digits' => Schema::TYPE_INTEGER . ' NOT NULL DEFAULT 2', 'dec_point' => Schema::TYPE_STRING . ' NOT NULL DEFAULT \'.\'', 'thousands_sep' => Schema::TYPE_STRING . ' NOT NULL DEFAULT \' \'', 'format_string' => Schema::TYPE_STRING, 'additional_rate' => Schema::TYPE_FLOAT . ' NOT NULL DEFAULT 0', 'additional_nominal' => Schema::TYPE_FLOAT . ' NOT NULL DEFAULT 0', 'currency_rate_provider_id' => Schema::TYPE_INTEGER . ' NOT NULL DEFAULT 0'], $tableOptions);
     //
     $this->createTable(Warehouse::tableName(), ['id' => Schema::TYPE_PK, 'name' => Schema::TYPE_STRING, 'is_active' => Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 1', 'country_id' => Schema::TYPE_INTEGER . ' NOT NULL', 'city_id' => Schema::TYPE_INTEGER . ' NOT NULL', 'address' => Schema::TYPE_TEXT, 'description' => Schema::TYPE_TEXT, 'sort_order' => Schema::TYPE_INTEGER . ' NOT NULL DEFAULT 0', 'map_latitude' => Schema::TYPE_STRING . ' NOT NULL DEFAULT \'\'', 'map_longitude' => Schema::TYPE_STRING . ' NOT NULL DEFAULT \'\'', 'shipping_center' => Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 1', 'issuing_center' => Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 1', 'xml_id' => Schema::TYPE_STRING . ' NOT NULL DEFAULT \'\'', 'KEY `wh_country` (`country_id`)', 'KEY `wh_city` (`city_id`)'], $tableOptions);
     $this->createTable(WarehousePhone::tableName(), ['id' => Schema::TYPE_PK, 'warehouse_id' => Schema::TYPE_INTEGER . ' NOT NULL', 'sort_order' => Schema::TYPE_INTEGER . ' NOT NULL DEFAULT 0', 'phone' => Schema::TYPE_STRING . ' NOT NULL', 'name' => Schema::TYPE_STRING, 'KEY `wh_phone` (`warehouse_id`)'], $tableOptions);
     $this->createTable(WarehouseEmail::tableName(), ['id' => Schema::TYPE_PK, 'warehouse_id' => Schema::TYPE_INTEGER . ' NOT NULL', 'sort_order' => Schema::TYPE_INTEGER . ' NOT NULL DEFAULT 0', 'email' => Schema::TYPE_STRING . ' NOT NULL', 'name' => Schema::TYPE_STRING, 'KEY `wh_email` (`warehouse_id`)'], $tableOptions);
     $this->createTable(WarehouseOpeninghours::tableName(), ['id' => Schema::TYPE_PK, 'warehouse_id' => Schema::TYPE_INTEGER . ' NOT NULL', 'sort_order' => Schema::TYPE_INTEGER . ' NOT NULL DEFAULT 0', 'monday' => Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 0', 'tuesday' => Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 0', 'wednesday' => Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 0', 'thursday' => Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 0', 'friday' => Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 0', 'saturday' => Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 0', 'sunday' => Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 0', 'all_day' => Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 0', 'opens' => Schema::TYPE_STRING, 'closes' => Schema::TYPE_STRING, 'break_from' => Schema::TYPE_STRING, 'break_to' => Schema::TYPE_STRING, 'KEY `wh_hours` (`warehouse_id`)'], $tableOptions);
     $this->createTable(Country::tableName(), ['id' => Schema::TYPE_PK, 'name' => Schema::TYPE_STRING, 'iso_code' => Schema::TYPE_STRING, 'sort_order' => Schema::TYPE_INTEGER . ' NOT NULL DEFAULT 0', 'slug' => Schema::TYPE_STRING], $tableOptions);
     $this->createTable(City::tableName(), ['id' => Schema::TYPE_PK, 'name' => Schema::TYPE_STRING, 'sort_order' => Schema::TYPE_INTEGER . ' NOT NULL DEFAULT 0', 'slug' => Schema::TYPE_STRING, 'country_id' => Schema::TYPE_INTEGER . ' NOT NULL', 'KEY `city_country` (`country_id`)'], $tableOptions);
     $this->createTable(WarehouseProduct::tableName(), ['id' => Schema::TYPE_PK, 'warehouse_id' => Schema::TYPE_INTEGER . ' NOT NULL', 'product_id' => Schema::TYPE_INTEGER . ' NOT NULL', 'in_warehouse' => Schema::TYPE_FLOAT . ' NOT NULL DEFAULT 0', 'reserved_count' => Schema::TYPE_FLOAT . ' NOT NULL DEFAULT 0', 'sku' => Schema::TYPE_STRING . ' NOT NULL DEFAULT \'\'', 'UNIQUE `wh_pr` (`warehouse_id`, `product_id`)'], $tableOptions);
     $this->createTable(RatingItem::tableName(), ['id' => Schema::TYPE_PK, 'name' => Schema::TYPE_STRING . ' NOT NULL', 'rating_group' => Schema::TYPE_STRING . ' NOT NULL', 'min_value' => Schema::TYPE_INTEGER . ' NOT NULL DEFAULT 0', 'max_value' => Schema::TYPE_INTEGER . ' NOT NULL DEFAULT 5', 'step_value' => Schema::TYPE_INTEGER . ' NOT NULL DEFAULT 1', 'require_review' => Schema::TYPE_BOOLEAN . ' DEFAULT 0', 'allow_guest' => 'TINYINT(1) DEFAULT \'0\'', 'KEY `ix-rating_item-rating_group` (`rating_group`)']);
     $this->createTable(RatingValues::tableName(), ['id' => Schema::TYPE_PK, 'rating_id' => 'CHAR(32) CHARACTER SET utf8 NOT NULL', 'object_id' => 'INT UNSIGNED NOT NULL', 'object_model_id' => 'INT UNSIGNED NOT NULL', 'rating_item_id' => 'INT UNSIGNED NOT NULL', 'value' => Schema::TYPE_INTEGER . ' NOT NULL DEFAULT 0', 'user_id' => 'INT UNSIGNED NOT NULL', 'date' => Schema::TYPE_DATETIME . ' NOT NULL', 'KEY `ix-rating_values-rating_id` (`rating_id`)', 'KEY `ix-rating_values-object_id-object_model_id` (`object_id`,`object_model_id`)']);
     $this->createTable(SpamChecker::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'behavior' => 'VARCHAR(255) NOT NULL', 'api_key' => 'VARCHAR(90) DEFAULT NULL', 'name' => 'VARCHAR(50) DEFAULT NULL', 'author_field' => 'VARCHAR(50) DEFAULT NULL', 'content_field' => 'VARCHAR(50) DEFAULT NULL'], $tableOptions);
     $this->createTable(Configurable::tableName(), ['id' => Schema::TYPE_PK, 'module' => Schema::TYPE_STRING . ' NOT NULL', 'sort_order' => Schema::TYPE_INTEGER . ' NOT NULL DEFAULT 0', 'section_name' => Schema::TYPE_STRING . ' NOT NULL', 'display_in_config' => Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 1'], $tableOptions);
     $this->createTable(Thumbnail::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'img_id' => 'INT UNSIGNED NOT NULL', 'thumb_path' => 'VARCHAR(255) NOT NULL', 'size_id' => 'INT UNSIGNED NOT NULL'], $tableOptions);
     $this->createTable(ThumbnailSize::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'width' => 'INT UNSIGNED NOT NULL', 'height' => 'INT UNSIGNED NOT NULL', 'default_watermark_id' => 'INT UNSIGNED NULL', 'resize_mode' => 'ENUM(\'' . ManipulatorInterface::THUMBNAIL_INSET . '\',\'' . ManipulatorInterface::THUMBNAIL_OUTBOUND . '\') DEFAULT \'' . ManipulatorInterface::THUMBNAIL_INSET . '\''], $tableOptions);
     $this->createTable(Watermark::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'watermark_path' => 'VARCHAR(255) NOT NULL', 'position' => 'enum(\'TOP LEFT\',\'TOP RIGHT\',\'BOTTOM LEFT\',\'BOTTOM RIGHT\',\'CENTER\') NOT NULL DEFAULT \'TOP LEFT\''], $tableOptions);
     $this->createTable(ThumbnailWatermark::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'thumb_id' => 'INT UNSIGNED NOT NULL', 'water_id' => 'INT UNSIGNED NOT NULL', 'compiled_src' => 'VARCHAR(255) NOT NULL'], $tableOptions);
     $this->createTable(ErrorImage::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'img_id' => 'INT UNSIGNED NOT NULL', 'class_name' => 'VARCHAR(255) NOT NULL'], $tableOptions);
     $this->createTable(ContentBlock::tableName(), ['id' => Schema::TYPE_PK, 'name' => 'VARCHAR(255) NOT NULL DEFAULT \'\'', 'key' => 'VARCHAR(255) NOT NULL DEFAULT \'\'', 'value' => Schema::TYPE_TEXT, 'preload' => 'TINYINT DEFAULT \'0\'']);
     $this->createTable(ContentDecorator::tableName(), ['id' => Schema::TYPE_PK, 'added_by_ext' => Schema::TYPE_STRING . ' NOT NULL', 'post_decorator' => Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 0', 'class_name' => Schema::TYPE_STRING . ' NOT NULL', 'sort_order' => Schema::TYPE_INTEGER . ' NOT NULL DEFAULT 0'], $tableOptions);
     $this->createTable(Events::tableName(), ['id' => Schema::TYPE_PK, 'owner_class_name' => Schema::TYPE_STRING . ' NOT NULL', 'event_name' => Schema::TYPE_STRING . ' NOT NULL', 'event_class_name' => Schema::TYPE_STRING . ' NOT NULL', 'selector_prefix' => Schema::TYPE_STRING . ' NOT NULL DEFAULT \'\'', 'event_description' => Schema::TYPE_TEXT . ' NOT NULL', 'documentation_link' => Schema::TYPE_STRING . ' NOT NULL DEFAULT \'\'', 'UNIQUE `event_class_name` (`event_class_name`(50))'], $tableOptions);
     $this->createTable(EventHandlers::tableName(), ['id' => Schema::TYPE_PK, 'event_id' => Schema::TYPE_INTEGER . ' NOT NULL DEFAULT 0', 'sort_order' => Schema::TYPE_INTEGER . ' NOT NULL DEFAULT 0', 'handler_class_name' => Schema::TYPE_STRING . ' NOT NULL', 'handler_function_name' => Schema::TYPE_STRING . ' NOT NULL', 'is_active' => Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 1', 'non_deletable' => Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 0', 'triggering_type' => Schema::TYPE_STRING . ' NOT NULL', 'KEY `by_event_active` (`event_id`, `is_active`)'], $tableOptions);
     $this->createTable(Extensions::tableName(), ['id' => Schema::TYPE_PK, 'name' => Schema::TYPE_STRING . ' NOT NULL', 'is_active' => Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 1', 'force_version' => Schema::TYPE_STRING . ' NOT NULL DEFAULT \'dev-master\'', 'type' => Schema::TYPE_INTEGER . ' NOT NULL DEFAULT 0', 'latest_version' => Schema::TYPE_STRING . ' NOT NULL DEFAULT \'\'', 'current_package_version_timestamp' => Schema::TYPE_TIMESTAMP . ' NULL', 'latest_package_version_timestamp' => Schema::TYPE_TIMESTAMP . ' NULL', 'homepage' => Schema::TYPE_STRING . ' NOT NULL DEFAULT \'\'', 'namespace_prefix' => Schema::TYPE_STRING . ' NOT NULL'], $tableOptions);
     $this->createTable(ExtensionTypes::tableName(), ['id' => Schema::TYPE_PK, 'name' => Schema::TYPE_STRING . ' NOT NULL'], $tableOptions);
     $this->createTable(CommercemlGuid::tableName(), ['id' => Schema::TYPE_PK, 'guid' => Schema::TYPE_STRING, 'name' => Schema::TYPE_TEXT, 'model_id' => Schema::TYPE_BIGINT, 'type' => 'ENUM(\'PRODUCT\', \'CATEGORY\', \'PROPERTY\') DEFAULT \'PRODUCT\''], $tableOptions);
     $this->createTable(OrderStage::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'name' => 'VARCHAR(255) NOT NULL', 'name_frontend' => 'VARCHAR(255) DEFAULT NULL', 'name_short' => 'VARCHAR(255) DEFAULT NULL', 'is_initial' => 'TINYINT(1) UNSIGNED NOT NULL DEFAULT 0', 'is_buyer_stage' => 'TINYINT(1) UNSIGNED NOT NULL DEFAULT 0', 'become_non_temporary' => 'TINYINT(1) UNSIGNED NOT NULL DEFAULT 0', 'is_in_cart' => 'TINYINT(1) UNSIGNED NOT NULL DEFAULT 0', 'immutable_by_user' => 'TINYINT(1) UNSIGNED NOT NULL DEFAULT 1', 'immutable_by_manager' => 'TINYINT(1) UNSIGNED NOT NULL DEFAULT 0', 'immutable_by_assigned' => 'TINYINT(1) UNSIGNED NOT NULL DEFAULT 0', 'reach_goal_ym' => 'VARCHAR(255) DEFAULT NULL', 'reach_goal_ga' => 'VARCHAR(255) DEFAULT NULL', 'event_name' => 'VARCHAR(255) DEFAULT NULL', 'view' => 'VARCHAR(255) DEFAULT NULL'], $tableOptions);
     $this->createTable(OrderStageLeaf::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'stage_from_id' => 'INT UNSIGNED NOT NULL', 'stage_to_id' => 'INT UNSIGNED NOT NULL', 'sort_order' => 'INT NOT NULL DEFAULT 0', 'button_label' => 'VARCHAR(255) NOT NULL', 'button_css_class' => 'VARCHAR(255) DEFAULT NULL', 'notify_buyer' => 'TINYINT(1) UNSIGNED NOT NULL DEFAULT 0', 'buyer_notification_view' => 'VARCHAR(255) DEFAULT NULL', 'notify_manager' => 'TINYINT(1) UNSIGNED NOT NULL DEFAULT 1', 'manager_notification_view' => 'VARCHAR(255) DEFAULT NULL', 'assign_to_user_id' => 'INT UNSIGNED NOT NULL DEFAULT 0', 'assign_to_role' => 'VARCHAR(255) DEFAULT NULL', 'notify_new_assigned_user' => 'TINYINT(1) UNSIGNED NOT NULL DEFAULT 1', 'role_assignment_policy' => "ENUM('random','fair_distribution','last_picked_from_role')", 'event_name' => 'VARCHAR(255) DEFAULT NULL'], $tableOptions);
     $this->createTable(Discount::tableName(), ['id' => Schema::TYPE_PK, 'name' => Schema::TYPE_STRING . ' NOT NULL', 'appliance' => "ENUM('order_without_delivery','order_with_delivery','products','product_categories','delivery') NOT NULL", 'value' => Schema::TYPE_FLOAT . ' NOT NULL', 'value_in_percent' => Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 1', 'apply_order_price_lg' => Schema::TYPE_FLOAT . ' NOT NULL DEFAULT -1']);
     $this->createTable(DiscountCode::tableName(), ['id' => Schema::TYPE_PK, 'code' => Schema::TYPE_STRING . ' NOT NULL', 'discount_id' => Schema::TYPE_INTEGER . ' NOT NULL', 'valid_from' => 'TIMESTAMP NULL DEFAULT NULL', 'valid_till' => 'TIMESTAMP NULL DEFAULT NULL', 'maximum_uses' => Schema::TYPE_INTEGER . ' DEFAULT NULL']);
     $this->createTable(CategoryDiscount::tableName(), ['id' => Schema::TYPE_PK, 'category_id' => Schema::TYPE_INTEGER . ' NOT NULL', 'discount_id' => Schema::TYPE_INTEGER . ' NOT NULL']);
     $this->createTable(UserDiscount::tableName(), ['id' => Schema::TYPE_PK, 'user_id' => Schema::TYPE_INTEGER . ' NOT NULL', 'discount_id' => Schema::TYPE_INTEGER . ' NOT NULL']);
     $this->createTable(OrderDiscount::tableName(), ['id' => Schema::TYPE_PK, 'order_id' => Schema::TYPE_INTEGER . ' NOT NULL', 'discount_id' => Schema::TYPE_INTEGER . ' NOT NULL', 'applied_date' => Schema::TYPE_TIMESTAMP]);
     $this->createTable(ProductDiscount::tableName(), ['id' => Schema::TYPE_PK, 'product_id' => Schema::TYPE_INTEGER . ' NOT NULL', 'discount_id' => Schema::TYPE_INTEGER . ' NOT NULL']);
     $this->createTable(DiscountType::tableName(), ['id' => Schema::TYPE_PK, 'name' => Schema::TYPE_STRING . ' NOT NULL', 'class' => Schema::TYPE_STRING . ' NOT NULL', 'active' => Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 1', 'checking_class' => "ENUM('Order','OrderItem') NOT NULL", 'sort_order' => Schema::TYPE_INTEGER . ' NOT NULL DEFAULT 0', 'add_view' => 'VARCHAR(255) DEFAULT NULL']);
     $this->createTable(SpecialPriceList::tableName(), ['id' => Schema::TYPE_PK, 'object_id' => Schema::TYPE_SMALLINT . ' NOT NULL', 'class' => Schema::TYPE_STRING . ' NOT NULL', 'active' => Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 1', 'sort_order' => Schema::TYPE_INTEGER . ' NOT NULL DEFAULT 0', 'params' => Schema::TYPE_TEXT, 'type' => "ENUM('core', 'discount', 'delivery', 'tax' ,'project') DEFAULT 'project'", 'handler' => 'VARCHAR(255) DEFAULT NULL']);
     $this->createTable(FilterSets::tableName(), ['id' => Schema::TYPE_PK, 'category_id' => Schema::TYPE_INTEGER . ' NOT NULL', 'sort_order' => Schema::TYPE_INTEGER . ' NOT NULL DEFAULT 0', 'property_id' => Schema::TYPE_INTEGER . ' NOT NULL DEFAULT 0', 'is_filter_by_price' => Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 0', 'delegate_to_children' => Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 1']);
     //
     $this->createTable(Customer::tableName(), ['id' => Schema::TYPE_PK, 'user_id' => Schema::TYPE_INTEGER . ' DEFAULT 0', 'first_name' => Schema::TYPE_STRING, 'middle_name' => Schema::TYPE_STRING, 'last_name' => Schema::TYPE_STRING, 'email' => Schema::TYPE_STRING, 'phone' => Schema::TYPE_STRING], $tableOptions);
     $this->createTable(Contragent::tableName(), ['id' => Schema::TYPE_PK, 'customer_id' => Schema::TYPE_INTEGER . ' NOT NULL', 'type' => "ENUM('Individual', 'Self-employed', 'Legal entity') NOT NULL DEFAULT 'Individual'"], $tableOptions);
     $this->createTable(DeliveryInformation::tableName(), ['id' => Schema::TYPE_PK, 'contragent_id' => Schema::TYPE_INTEGER . ' NOT NULL', 'country_id' => Schema::TYPE_INTEGER . ' DEFAULT 0', 'city_id' => Schema::TYPE_INTEGER . ' DEFAULT 0', 'zip_code' => Schema::TYPE_STRING, 'address' => Schema::TYPE_TEXT], $tableOptions);
     $this->createTable(OrderDeliveryInformation::tableName(), ['id' => Schema::TYPE_PK, 'order_id' => Schema::TYPE_INTEGER . ' NOT NULL', 'shipping_option_id' => Schema::TYPE_INTEGER . ' NOT NULL', 'shipping_price' => Schema::TYPE_FLOAT . ' NOT NULL DEFAULT 0', 'shipping_price_total' => Schema::TYPE_FLOAT . ' NOT NULL DEFAULT 0', 'planned_delivery_date' => Schema::TYPE_DATE, 'planned_delivery_time' => Schema::TYPE_TIME, 'planned_delivery_time_range' => Schema::TYPE_STRING], $tableOptions);
     $this->createTable('{{%customer_eav}}', ['id' => Schema::TYPE_PK, 'object_model_id' => Schema::TYPE_INTEGER . ' UNSIGNED NOT NULL', 'property_group_id' => Schema::TYPE_INTEGER . ' UNSIGNED NOT NULL', 'key' => Schema::TYPE_STRING . ' NOT NULL', 'value' => Schema::TYPE_TEXT, 'sort_order' => Schema::TYPE_INTEGER], $tableOptions);
     $this->createTable('{{%contragent_eav}}', ['id' => Schema::TYPE_PK, 'object_model_id' => Schema::TYPE_INTEGER . ' UNSIGNED NOT NULL', 'property_group_id' => Schema::TYPE_INTEGER . ' UNSIGNED NOT NULL', 'key' => 'VARCHAR(255) NOT NULL', 'value' => Schema::TYPE_TEXT, 'sort_order' => Schema::TYPE_INTEGER], $tableOptions);
     $this->createTable('{{%order_delivery_information_eav}}', ['id' => Schema::TYPE_PK, 'object_model_id' => Schema::TYPE_INTEGER . ' UNSIGNED NOT NULL', 'property_group_id' => Schema::TYPE_INTEGER . ' UNSIGNED NOT NULL', 'key' => Schema::TYPE_STRING . ' NOT NULL', 'value' => Schema::TYPE_TEXT, 'sort_order' => Schema::TYPE_INTEGER], $tableOptions);
     $this->createTable(Measure::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'name' => 'VARCHAR(255) NOT NULL', 'symbol' => 'VARCHAR(255) NOT NULL', 'nominal' => 'FLOAT NOT NULL'], $tableOptions);
     $this->createTable(SpecialPriceObject::tableName(), ['id' => Schema::TYPE_PK, 'special_price_list_id' => Schema::TYPE_INTEGER . ' NOT NULL', 'object_model_id' => Schema::TYPE_INTEGER . ' NOT NULL', 'price' => Schema::TYPE_FLOAT . ' NOT NULL DEFAULT 0', 'name' => 'VARCHAR(255) DEFAULT NULL']);
     $this->createTable(ThemeParts::tableName(), ['id' => Schema::TYPE_PK, 'name' => Schema::TYPE_STRING, 'key' => Schema::TYPE_STRING, 'global_visibility' => Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 1', 'multiple_widgets' => Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 1', 'is_cacheable' => Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 1', 'cache_lifetime' => Schema::TYPE_INTEGER . ' NOT NULL DEFAULT 0', 'cache_tags' => Schema::TYPE_TEXT . ' NULL', 'cache_vary_by_session' => Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 0'], $tableOptions);
     $this->createTable(ThemeWidgets::tableName(), ['id' => Schema::TYPE_PK, 'name' => Schema::TYPE_STRING, 'widget' => Schema::TYPE_STRING, 'preview_image' => Schema::TYPE_STRING . ' NULL', 'configuration_model' => Schema::TYPE_STRING . ' NULL', 'configuration_view' => Schema::TYPE_STRING . ' NULL', 'configuration_json' => Schema::TYPE_TEXT . ' NULL', 'is_cacheable' => Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 1', 'cache_lifetime' => Schema::TYPE_INTEGER . ' NOT NULL DEFAULT 0', 'cache_tags' => Schema::TYPE_TEXT . ' NULL', 'cache_vary_by_session' => Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 0'], $tableOptions);
     $this->createTable(ThemeVariation::tableName(), ['id' => Schema::TYPE_PK, 'name' => Schema::TYPE_STRING . ' NULL', 'by_url' => Schema::TYPE_STRING . ' NULL', 'by_route' => Schema::TYPE_STRING . ' NULL', 'matcher_class_name' => Schema::TYPE_STRING . ' NULL', 'exclusive' => Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 0'], $tableOptions);
     $this->createTable(ThemeWidgetApplying::tableName(), ['id' => Schema::TYPE_PK, 'widget_id' => Schema::TYPE_INTEGER, 'part_id' => Schema::TYPE_INTEGER, 'UNIQUE `widget_part` (`widget_id`, `part_id`)'], $tableOptions);
     $this->createTable(ThemeActiveWidgets::tableName(), ['id' => Schema::TYPE_PK, 'part_id' => Schema::TYPE_INTEGER, 'widget_id' => Schema::TYPE_INTEGER, 'variation_id' => Schema::TYPE_INTEGER, 'sort_order' => Schema::TYPE_INTEGER . ' NOT NULL DEFAULT 0', 'configuration_json' => Schema::TYPE_TEXT, 'KEY `variation` (`variation_id`)'], $tableOptions);
     $this->createTable(\app\modules\seo\models\Config::tableName(), ['key' => 'VARCHAR(255) NOT NULL PRIMARY KEY', 'value' => 'TEXT NOT NULL'], $tableOptions);
     $this->createTable(\app\modules\seo\models\Counter::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'name' => 'VARCHAR(255) DEFAULT NULL', 'description' => 'TEXT DEFAULT NULL', 'code' => 'TEXT NOT NULL '], $tableOptions);
     $this->createTable(\app\modules\seo\models\LinkAnchor::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'model_name' => 'VARCHAR(60) NOT NULL', 'model_id' => 'INT UNSIGNED NOT NULL', 'anchor' => 'TEXT NOT NULL', 'sort_order' => 'INT DEFAULT \'0\''], $tableOptions);
     $this->createTable(\app\modules\seo\models\LinkAnchorBinding::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'link_anchor_id' => 'INT UNSIGNED NOT NULL', 'view_file' => 'VARCHAR(255) NOT NULL', 'params_hash' => 'VARCHAR(255) DEFAULT NULL', 'model_name' => 'VARCHAR(255) NOT NULL', 'model_id' => 'VARCHAR(255) NOT NULL', 'KEY `ix-link_anchor_id` (`link_anchor_id`)', 'KEY `model_name` (`model_name`, `model_id`)'], $tableOptions);
     $this->createTable(\app\modules\seo\models\ModelAnchorIndex::tableName(), ['model_name' => 'VARCHAR(255) NOT NULL PRIMARY KEY', 'model_id' => 'VARCHAR(255) NOT NULL', 'next_index' => 'INT UNSIGNED NOT NULL'], $tableOptions);
     $this->createTable(\app\modules\seo\models\Redirect::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'type' => 'enum(\'STATIC\',\'PREG\') NOT NULL DEFAULT \'STATIC\'', 'from' => 'VARCHAR(255) NOT NULL', 'to' => 'VARCHAR(255) NOT NULL', 'active' => 'TINYINT NOT NULL DEFAULT \'1\''], $tableOptions);
     $this->createTable(\app\modules\seo\models\Meta::tableName(), ['key' => 'VARCHAR(255) NOT NULL PRIMARY KEY', 'name' => 'VARCHAR(255) NOT NULL', 'content' => 'VARCHAR(255) NOT NULL '], $tableOptions);
     $this->createTable(\app\modules\seo\models\Sitemap::tableName(), ['uid' => 'VARCHAR(255) NOT NULL PRIMARY KEY', 'url' => 'VARCHAR(255) NOT NULL'], $tableOptions);
     $this->createTable(OrderCode::tableName(), ['id' => Schema::TYPE_PK, 'order_id' => Schema::TYPE_INTEGER . ' NOT NULL', 'discount_code_id' => Schema::TYPE_INTEGER . ' NOT NULL', 'status' => Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 0']);
     // Data
     // Backend menu
     $this->insert(BackendMenu::tableName(), ['parent_id' => 0, 'name' => 'Root', 'route' => '/backend/', 'added_by_ext' => 'core']);
     $rootId = $this->db->lastInsertID;
     $this->batchInsert(BackendMenu::tableName(), ['parent_id', 'name', 'route', 'icon', 'added_by_ext', 'rbac_check'], [[$rootId, 'Dashboard', 'backend/dashboard/index', 'dashboard', 'core', 'administrate'], [$rootId, 'Pages', 'page/backend/index', 'file-o', 'core', 'content manage']]);
     $this->insert(BackendMenu::tableName(), ['parent_id' => $rootId, 'name' => 'Shop', 'icon' => 'shopping-cart', 'added_by_ext' => 'core', 'rbac_check' => 'shop manage', 'route' => '']);
     $lastId = $this->db->lastInsertID;
     $this->batchInsert(BackendMenu::tableName(), ['parent_id', 'name', 'route', 'icon', 'added_by_ext', 'rbac_check'], [[$lastId, 'Categories', 'shop/backend-category/index', 'tree', 'core', 'category manage'], [$lastId, 'Products', 'shop/backend-product/index', 'list', 'core', 'product manage'], [$lastId, 'Orders', 'shop/backend-order/index', 'list-alt', 'core', 'order manage'], [$lastId, 'Stages', 'shop/backend-stage/index', 'sitemap', 'core', 'order status manage'], [$lastId, 'Payment types', 'shop/backend-payment-type/index', 'info-circle', 'core', 'payment manage'], [$lastId, 'Filter sets', 'shop/backend-filter-sets/index', 'filter', 'core', 'category manage'], [$lastId, 'Shipping options', 'shop/backend-shipping-option/index', 'truck', 'core', 'shipping manage'], [$lastId, 'Categories groups', 'shop/backend-category-group/index', 'folder-o', 'core', 'category manage'], [$lastId, 'Prefiltered pages', 'shop/backend-prefiltered-pages/index', 'tag', 'core', 'shop manage'], [$lastId, 'Currencies', 'shop/backend-currencies/index', 'usd', 'core', 'shop manage'], [$lastId, 'Measures', 'shop/backend-measure/index', 'calculator', 'core', 'shop manage'], [$lastId, 'Discounts', 'shop/backend-discount/index', 'shekel', 'core', 'shop manage'], [$lastId, 'Warehouse', 'shop/backend-warehouse/index', 'cubes', 'core', 'shop manage']]);
     $this->insert(BackendMenu::tableName(), ['parent_id' => $rootId, 'name' => 'Properties', 'icon' => 'cogs', 'added_by_ext' => 'core', 'rbac_check' => 'property manage', 'route' => '']);
     $lastId = $this->db->lastInsertID;
     $this->batchInsert(BackendMenu::tableName(), ['parent_id', 'name', 'route', 'icon', 'added_by_ext', 'rbac_check'], [[$lastId, 'Properties', 'backend/properties/index', 'cogs', 'core', 'property manage'], [$lastId, 'Views', 'backend/view/index', 'desktop', 'core', 'view manage']]);
     $this->batchInsert(BackendMenu::tableName(), ['parent_id', 'name', 'route', 'icon', 'added_by_ext', 'rbac_check'], [[$rootId, 'Reviews', 'review/backend-review/index', 'comment', 'core', 'review manage'], [$rootId, 'Rating groups', 'review/backend-rating/index', 'star-half-o', 'core', 'review manage'], [$rootId, 'Navigation', 'backend/navigation/index', 'navicon', 'core', 'navigation manage'], [$rootId, 'Forms', 'backend/form/index', 'list-ul', 'core', 'form manage'], [$rootId, 'Dynamic content', 'backend/dynamic-content/index', 'puzzle-piece', 'core', 'content manage'], [$rootId, 'Content Blocks', 'core/backend-chunk/index', 'file-code-o', 'core', 'content manage'], [$rootId, 'Sliders', 'backend/slider/index', 'arrows-h', 'core', 'content manage'], [$rootId, 'Users', 'user/backend-user/index', 'users', 'core', 'user manage'], [$rootId, 'Rbac', 'user/rbac/index', 'lock', 'core', 'user manage'], [$rootId, 'Seo', 'seo/manage/index', 'search', 'core', 'seo manage']]);
     $this->insert(BackendMenu::tableName(), ['parent_id' => $rootId, 'name' => 'Images', 'icon' => 'picture-o', 'added_by_ext' => 'core', 'rbac_check' => 'content manage', 'route' => '']);
     $lastId = $this->db->lastInsertID;
     $this->batchInsert(BackendMenu::tableName(), ['parent_id', 'name', 'route', 'added_by_ext', 'rbac_check'], [[$lastId, 'Thumbnails sizes', 'image/backend-thumbnail-size/index', 'core', 'content manage'], [$lastId, 'Create thumbnails', 'image/backend-thumbnail/index', 'core', 'content manage'], [$lastId, 'Watermarks', 'image/backend-watermark/index', 'core', 'content manage'], [$lastId, 'Broken images', 'image/backend-error-images/index', 'core', 'content manage']]);
     $this->insert(BackendMenu::tableName(), ['parent_id' => $rootId, 'name' => 'Error monitoring', 'icon' => 'flash', 'added_by_ext' => 'core', 'rbac_check' => 'monitoring manage', 'route' => 'backend/error-monitor/index']);
     $this->insert(BackendMenu::tableName(), ['parent_id' => $rootId, 'name' => 'Settings', 'icon' => 'gears', 'added_by_ext' => 'core', 'rbac_check' => 'setting manage', 'route' => '']);
     $lastId = $this->db->lastInsertID;
     $this->batchInsert(BackendMenu::tableName(), ['parent_id', 'name', 'route', 'icon', 'added_by_ext', 'rbac_check'], [[$lastId, 'Tasks', 'background/manage/index', 'tasks', 'core', 'task manage'], [$lastId, 'Config', 'config/backend/index', 'gear', 'core', 'setting manage'], [$lastId, 'I18n', 'backend/i18n/index', 'language', 'core', 'setting manage'], [$lastId, 'Spam Form Checker', 'backend/spam-checker/index', 'send-o', 'core', 'setting manage'], [$lastId, 'Backend menu', 'backend/backend-menu/index', 'list-alt', 'core', 'setting manage'], [$lastId, 'Data', 'data/file/index', 'database', 'core', 'data manage'], [$lastId, 'YML', 'shop/backend-yml/settings', 'code', 'core', 'content manage'], [$lastId, 'Api', 'backend/api/index', 'exchange', 'core', 'api manage']]);
     //
     $this->batchInsert(Object::tableName(), ['name', 'object_class', 'object_table_name', 'column_properties_table_name', 'eav_table_name', 'categories_table_name', 'link_slug_category', 'link_slug_static_value', 'object_slug_attribute'], [['Page', Page::className(), Yii::$app->db->schema->getRawTableName(Page::tableName()), Yii::$app->db->schema->getRawTableName('{{%page_property}}'), Yii::$app->db->schema->getRawTableName('{{%page_eav}}'), Yii::$app->db->schema->getRawTableName('{{%page_category}}'), Yii::$app->db->schema->getRawTableName('{{%page_category_full_slug}}'), Yii::$app->db->schema->getRawTableName('{{%page_static_value_category}}'), 'slug'], ['Category', Category::className(), Yii::$app->db->schema->getRawTableName(Category::tableName()), Yii::$app->db->schema->getRawTableName('{{%category_property}}'), Yii::$app->db->schema->getRawTableName('{{%category_eav}}'), Yii::$app->db->schema->getRawTableName('{{%category_category}}'), Yii::$app->db->schema->getRawTableName('{{%category_category_full_slug}}'), Yii::$app->db->schema->getRawTableName('{{%category_static_value_category}}'), 'slug']]);
     $this->insert(Object::tableName(), ['name' => 'Product', 'object_class' => Product::className(), 'object_table_name' => Yii::$app->db->schema->getRawTableName(Product::tableName()), 'column_properties_table_name' => Yii::$app->db->schema->getRawTableName('{{%product_property}}'), 'eav_table_name' => Yii::$app->db->schema->getRawTableName('{{%product_eav}}'), 'categories_table_name' => Yii::$app->db->schema->getRawTableName('{{%product_category}}'), 'link_slug_category' => Yii::$app->db->schema->getRawTableName('{{%product_category_full_slug}}'), 'link_slug_static_value' => Yii::$app->db->schema->getRawTableName('{{%product_static_value_category}}'), 'object_slug_attribute' => 'slug']);
     $lastInsertId = Yii::$app->db->lastInsertID;
     $this->batchInsert(Route::tableName(), ['route', 'url_template', 'object_id', 'name'], [['shop/product/list', Json::encode([["class" => "app\\properties\\url\\StaticPart", "static_part" => "catalog", "parameters" => ["category_group_id" => 1]], ["class" => "app\\properties\\url\\PartialCategoryPathPart", "category_group_id" => 1]]), $lastInsertId, ''], ['shop/product/show', Json::encode([["class" => "app\\properties\\url\\StaticPart", "static_part" => "catalog", "parameters" => ["category_group_id" => 1]], ["class" => "app\\properties\\url\\FullCategoryPathPart", "category_group_id" => 1], ["class" => "app\\properties\\url\\ObjectSlugPart"]]), $lastInsertId, '']]);
     $this->batchInsert(PropertyHandler::tableName(), ['name', 'frontend_render_view', 'frontend_edit_view', 'backend_render_view', 'backend_edit_view', 'handler_class_name'], [['Text', 'frontend-render', 'frontend-edit', 'backend-render', 'backend-edit', 'app\\properties\\handlers\\text\\TextProperty'], ['Select', 'frontend-render', 'frontend-edit', 'backend-render', 'backend-edit', 'app\\properties\\handlers\\select\\SelectProperty'], ['Checkbox', 'frontend-render', 'frontend-edit', 'backend-render', 'backend-edit', 'app\\properties\\handlers\\checkbox\\CheckboxProperty'], ['Text area', 'frontend-render', 'frontend-edit', 'backend-render', 'backend-edit', 'app\\properties\\handlers\\textArea\\TextAreaProperty'], ['File', 'frontend-render', 'frontend-edit', 'backend-render', 'backend-edit', 'app\\properties\\handlers\\fileInput\\FileInputProperty'], ['Hidden', 'frontend-render', 'frontend-edit', 'backend-render', 'backend-edit', 'app\\properties\\handlers\\hidden\\HiddenProperty'], ['Redactor', 'frontend-render', 'frontend-edit', 'backend-render', 'backend-edit', 'app\\properties\\handlers\\redactor\\RedactorProperty']]);
     $this->batchInsert(Layout::tableName(), ['name', 'layout'], [['Default', '\\\\layouts\\main'], ['Main page', '\\\\layouts\\main-page'], ['Page without sidebar', '\\\\layouts\\no-sidebar']]);
     $this->insert(View::tableName(), ['name' => 'Default', 'view' => 'default', 'category' => 'app', 'internal_name' => 'default']);
     $this->insert(Page::tableName(), ['slug' => ':mainpage:', 'content' => 'This is main page!', 'parent_id' => 0, 'title' => 'Main page']);
     $this->insert(CategoryGroup::tableName(), ['name' => 'Shop']);
     $this->insert(Category::tableName(), ['category_group_id' => Yii::$app->db->lastInsertID, 'parent_id' => 0, 'name' => Yii::t('app', 'Catalog'), 'title' => Yii::t('app', 'Catalog'), 'h1' => Yii::t('app', 'Catalog'), 'meta_description' => Yii::t('app', 'Catalog'), 'breadcrumbs_label' => Yii::t('app', 'Catalog'), 'slug' => 'catalog', 'slug_compiled' => 'catalog']);
     $this->batchInsert(ShippingOption::tableName(), ['name', 'description', 'price_from', 'price_to', 'cost', 'sort', 'active'], [[Yii::t('app', 'Self-pickup'), '', '0', '0', '0', '1', '1'], [Yii::t('app', 'Delivery of mail'), '', '0', '0', '100', '2', '1']]);
     $this->batchInsert(PaymentType::tableName(), ['name', 'class', 'params', 'active', 'sort'], [[Yii::t('app', 'Cash'), app\components\payment\CashPayment::className(), '[]', '1', '1'], ['Robokassa', app\components\payment\RobokassaPayment::className(), Json::encode(['merchantLogin' => '', 'merchantPass1' => '', 'merchantPass2' => '', 'merchantUrl' => '']), '1', '2'], ['PayU', app\components\payment\PayUPayment::className(), Json::encode(['merchantName' => '', 'secretKey' => '']), '0', '3'], ['RBK Money', app\components\payment\RBKMoneyPayment::className(), Json::encode(['eshopId' => '', 'currency' => 'RUR', 'language' => 'ru', 'secretKey' => '', 'serviceName' => '']), '0', '4'], ['IntellectMoney', app\components\payment\IntellectMoneyPayment::className(), Json::encode(['eshopId' => '', 'currency' => 'RUR', 'language' => 'ru', 'secretKey' => '', 'serviceName' => '']), '0', '5'], ['Interkassa', app\components\payment\InterkassaPayment::className(), Json::encode(['checkoutId' => '', 'currency' => 'RUB', 'locale' => 'ru', 'secretKey' => '']), '0', '6'], ['Futubank', app\components\payment\FutubankPayment::className(), Json::encode(['testing' => '1', 'merchant' => '', 'currency' => 'RUB', 'secretKey' => '']), '0', '7'], ['Pay2Pay', app\components\payment\Pay2PayPayment::className(), Json::encode(['hiddenKey' => '', 'currency' => 'RUB', 'language' => 'ru', 'merchantId' => '', 'secretKey' => '', 'testMode' => 0]), '0', '8'], ['SpryPay', app\components\payment\SpryPayPayment::className(), Json::encode(['currency' => 'rur', 'language' => 'ru', 'shopId' => '', 'secretKey' => '']), '0', '9'], ['WalletOne', app\components\payment\WalletOnePayment::className(), Json::encode(['currency' => 643, 'locale' => 'ru-RU', 'merchantId' => '', 'secretKey' => '']), '0', '10'], ['PayOnline', app\components\payment\PayOnlinePayment::className(), Json::encode(['currency' => 'RUB', 'language' => 'ru', 'merchantId' => '', 'privateKey' => '']), '0', '11'], ['LiqPay', app\components\payment\LiqPayPayment::className(), Json::encode(['currency' => 'RUB', 'language' => 'ru', 'privateKey' => '', 'publicKey' => '']), '0', '12'], ['Platron', app\modules\shop\models\PaymentType::tableName(), Json::encode(['merchantId' => '', 'secretKey' => '', 'strCurrency' => 'RUR', 'merchantUrl' => 'www.platron.ru', 'merchantScriptName' => 'payment.php']), 0, 13]]);
     $this->insert(Object::tableName(), ['name' => 'Order', 'object_class' => Order::className(), 'object_table_name' => Yii::$app->db->schema->getRawTableName(Order::tableName()), 'column_properties_table_name' => Yii::$app->db->schema->getRawTableName('{{%order_property}}'), 'eav_table_name' => Yii::$app->db->schema->getRawTableName('{{%order_eav}}'), 'categories_table_name' => Yii::$app->db->schema->getRawTableName('{{%order_category}}'), 'link_slug_category' => Yii::$app->db->schema->getRawTableName('{{%order_category_full_slug}}'), 'link_slug_static_value' => Yii::$app->db->schema->getRawTableName('{{%order_static_value_full_slug}}'), 'object_slug_attribute' => 'slug']);
     $this->insert(PropertyGroup::tableName(), ['object_id' => Yii::$app->db->lastInsertID, 'name' => 'Order form', 'hidden_group_title' => 1]);
     $propertyGroupId = Yii::$app->db->lastInsertID;
     $this->batchInsert(Property::tableName(), ['property_group_id', 'name', 'key', 'property_handler_id', 'is_eav', 'handler_additional_params'], [[$propertyGroupId, 'Name', 'name', 1, 1, '{"rules":["required"]}'], [$propertyGroupId, 'Phone', 'phone', 1, 1, '{"rules":["required"]}'], [$propertyGroupId, 'E-mail', 'email', 1, 1, '{"rules":["required"]}'], [$propertyGroupId, 'Address', 'address', 1, 1, '{"rules":["required"]}']]);
     $this->batchInsert(Object::tableName(), ['name', 'object_class', 'object_table_name', 'column_properties_table_name', 'eav_table_name', 'categories_table_name', 'link_slug_category', 'link_slug_static_value', 'object_slug_attribute'], [['Form', \app\models\Form::className(), Yii::$app->db->schema->getRawTableName(\app\models\Form::tableName()), Yii::$app->db->schema->getRawTableName('{{%form_property}}'), Yii::$app->db->schema->getRawTableName('{{%form_eav}}'), Yii::$app->db->schema->getRawTableName('{{%form_category}}'), Yii::$app->db->schema->getRawTableName('{{%form_category_full_slug}}'), Yii::$app->db->schema->getRawTableName('{{%form_static_value_full_sluug}}'), 'slug'], ['Submission', \app\models\Submission::className(), Yii::$app->db->schema->getRawTableName(\app\models\Submission::tableName()), Yii::$app->db->schema->getRawTableName('{{%submission_property}}'), Yii::$app->db->schema->getRawTableName('{{%submission_eav}}'), Yii::$app->db->schema->getRawTableName('{{%submission_category}}'), Yii::$app->db->schema->getRawTableName('{{%submission_category_full_slug}}'), Yii::$app->db->schema->getRawTableName('{{%submission_static_value_full_slug}}'), 'slug']]);
     $this->insert(Object::tableName(), ['name' => 'User', 'object_class' => User::className(), 'object_table_name' => Yii::$app->db->schema->getRawTableName(User::tableName()), 'column_properties_table_name' => Yii::$app->db->schema->getRawTableName('{{%user_property}}'), 'eav_table_name' => Yii::$app->db->schema->getRawTableName('{{%user_eav}}'), 'categories_table_name' => Yii::$app->db->schema->getRawTableName('{{%user_category}}'), 'link_slug_category' => Yii::$app->db->schema->getRawTableName('{{%user_category_full_slug}}'), 'link_slug_static_value' => Yii::$app->db->schema->getRawTableName('{{%user_static_value_full_slug}}'), 'object_slug_attribute' => 'slug']);
     $this->insert(PropertyGroup::tableName(), ['object_id' => Yii::$app->db->lastInsertID, 'name' => 'User form']);
     $this->insert(Navigation::tableName(), ['parent_id' => 0, 'name' => 'Main menu', 'route_params' => '{}']);
     $this->batchInsert('{{%auth_item}}', ['name', 'type', 'description'], [['admin', '1', Yii::t('app', 'Administrator')], ['manager', '1', Yii::t('app', 'Manager')], ['administrate', '2', Yii::t('app', 'Administrate panel')], ['api manage', '2', Yii::t('app', 'API management')], ['seo manage', '2', Yii::t('app', 'SEO management')], ['task manage', '2', Yii::t('app', 'Task management')], ['user manage', '2', Yii::t('app', 'User management')], ['cache manage', '2', Yii::t('app', 'Cache management')], ['content manage', '2', Yii::t('app', 'Content management')], ['shop manage', '2', Yii::t('app', 'Shop management')], ['order manage', '2', Yii::t('app', 'Order management')], ['category manage', '2', Yii::t('app', 'Category management')], ['product manage', '2', Yii::t('app', 'Product management')], ['property manage', '2', Yii::t('app', 'Property management')], ['view manage', '2', Yii::t('app', 'View management')], ['review manage', '2', Yii::t('app', 'Review management')], ['navigation manage', '2', Yii::t('app', 'Navigation management')], ['form manage', '2', Yii::t('app', 'Form management')], ['media manage', '2', Yii::t('app', 'Media management')], ['order status manage', '2', Yii::t('app', 'Order status management')], ['payment manage', '2', Yii::t('app', 'Payment type management')], ['shipping manage', '2', Yii::t('app', 'Shipping option management')], ['monitoring manage', '2', Yii::t('app', 'Monitoring management')], ['data manage', '2', Yii::t('app', 'Data management')], ['setting manage', '2', Yii::t('app', 'Setting management')]]);
     $this->batchInsert('{{%auth_item_child}}', ['parent', 'child'], [['shop manage', 'category manage'], ['shop manage', 'product manage'], ['shop manage', 'order manage'], ['manager', 'administrate'], ['manager', 'content manage'], ['manager', 'order manage'], ['manager', 'shop manage'], ['manager', 'category manage'], ['manager', 'product manage'], ['manager', 'property manage'], ['manager', 'view manage'], ['manager', 'review manage'], ['manager', 'navigation manage'], ['manager', 'form manage'], ['manager', 'media manage'], ['admin', 'administrate'], ['admin', 'api manage'], ['admin', 'order manage'], ['admin', 'seo manage'], ['admin', 'task manage'], ['admin', 'user manage'], ['admin', 'cache manage'], ['admin', 'content manage'], ['admin', 'shop manage'], ['admin', 'category manage'], ['admin', 'product manage'], ['admin', 'property manage'], ['admin', 'view manage'], ['admin', 'review manage'], ['admin', 'navigation manage'], ['admin', 'form manage'], ['admin', 'media manage'], ['admin', 'order status manage'], ['admin', 'payment manage'], ['admin', 'shipping manage'], ['admin', 'monitoring manage'], ['admin', 'data manage'], ['admin', 'setting manage']]);
     // demo data
     //
     //
     //
     $this->insert(Task::tableName(), ['action' => 'seo/sitemap/generate-sitemap', 'type' => Task::TYPE_REPEAT, 'initiator' => 1, 'name' => 'sitemap', 'cron_expression' => '0-59/15 * * * *']);
     $this->insert(Task::tableName(), ['action' => 'errornotifier/notify', 'type' => Task::TYPE_REPEAT, 'initiator' => 1, 'name' => 'ErrorMonitor notifier', 'cron_expression' => '*/1 * * * *', 'status' => 'ACTIVE']);
     $this->batchInsert(ProductListingSort::tableName(), ['name', 'sort_field', 'asc_desc', 'enabled', 'sort_order'], [['Popularity', 'product.sort_order', 'asc', 1, 0], ['Price 0-9', 'product.price', 'asc', 1, 1], ['Price 9-0', 'product.price', 'desc', 1, 2], ['Name', 'product.name', 'asc', 1, 3], ['Name', 'product.name', 'desc', 1, 4]]);
     $this->batchInsert(SliderHandler::tableName(), ['name', 'slider_widget', 'slider_edit_view_file', 'edit_model'], [['Bootstrap 3 carousel', 'app\\slider\\sliders\\bootstrap3\\Bootstrap3CarouselWidget', '@app/slider/sliders/bootstrap3/views/edit', 'app\\slider\\sliders\\bootstrap3\\models\\EditModel'], ['Slick', 'app\\slider\\sliders\\slick\\SlickCarouselWidget', '@app/slider/sliders/slick/views/edit', 'app\\slider\\sliders\\slick\\models\\EditModel']]);
     $this->batchInsert(Slider::tableName(), ['name', 'slider_handler_id', 'image_width', 'image_height'], [['Example carousel', 1, 900, 350]]);
     $this->batchInsert(Slide::tableName(), ['slider_id', 'sort_order', 'image', 'link'], [[1, 1, 'http://st-1.dotplant.ru/img/dotplant-slider-demo/slide-1.jpg', '#1'], [1, 2, 'http://st-1.dotplant.ru/img/dotplant-slider-demo/slide-2.jpg', '#2'], [1, 3, 'http://st-1.dotplant.ru/img/dotplant-slider-demo/slide-3.jpg', '#3']]);
     $this->insert(CurrencyRateProvider::tableName(), ['name' => 'Google Finance', 'class_name' => 'Swap\\Provider\\GoogleFinanceProvider']);
     $this->insert(CurrencyRateProvider::tableName(), ['name' => 'Cbr Finance', 'class_name' => 'app\\components\\swap\\provider\\CbrFinanceProvider']);
     $this->insert(Currency::tableName(), ['name' => 'Ruble', 'iso_code' => 'RUB', 'is_main' => 1, 'format_string' => '# руб.', 'intl_formatting' => 0]);
     $this->insert(Currency::tableName(), ['name' => 'US Dollar', 'iso_code' => 'USD', 'convert_nominal' => 1, 'convert_rate' => 62.8353, 'sort_order' => 1, 'format_string' => '$ #', 'thousands_sep' => '.', 'dec_point' => ',']);
     $this->insert(Currency::tableName(), ['name' => 'Euro', 'iso_code' => 'EUR', 'convert_rate' => 71.32429999999999, 'format_string' => '&euro; #']);
     $this->insert(Task::tableName(), ['action' => 'currency/update', 'type' => 'REPEAT', 'initiator' => 1, 'name' => 'Currency update', 'cron_expression' => '0 0 * * *']);
     $this->insert(Country::tableName(), ['name' => 'Россия', 'iso_code' => 'RUS', 'sort_order' => 0, 'slug' => 'rossiya']);
     $this->insert(Country::tableName(), ['name' => 'USA', 'iso_code' => 'USA', 'sort_order' => 1, 'slug' => 'usa']);
     $this->insert(City::tableName(), ['name' => 'Москва', 'slug' => 'moscow', 'country_id' => 1]);
     $this->insert(City::tableName(), ['name' => 'Санкт-Петербург', 'slug' => 'spb', 'country_id' => 1]);
     $this->insert(City::tableName(), ['name' => 'New York', 'slug' => 'ny', 'country_id' => 2]);
     $this->insert(Warehouse::tableName(), ['name' => 'Main warehouse', 'country_id' => 1, 'city_id' => 1, 'address' => 'Kremlin']);
     $this->insert(WarehousePhone::tableName(), ['name' => 'Sales', 'warehouse_id' => 1, 'phone' => '+7 (495) 123-45-67']);
     $this->insert(WarehouseEmail::tableName(), ['name' => 'Sales', 'warehouse_id' => 1, 'email' => '*****@*****.**']);
     $this->insert(WarehouseOpeninghours::tableName(), ['warehouse_id' => 1, 'monday' => 1, 'tuesday' => 1, 'wednesday' => 1, 'thursday' => 1, 'friday' => 1, 'saturday' => 1, 'sunday' => 1, 'all_day' => 1, 'opens' => '', 'closes' => '', 'break_from' => '12:00', 'break_to' => '13:00']);
     $this->insert(Warehouse::tableName(), ['name' => 'Second warehouse', 'country_id' => 2, 'city_id' => 3, 'address' => 'The WallStreet hidden warehouse']);
     $this->insert(WarehousePhone::tableName(), ['name' => 'Sales', 'warehouse_id' => 2, 'phone' => '+1 800 1-WAREHOUSE-1']);
     $this->insert(WarehouseEmail::tableName(), ['name' => 'Sales', 'warehouse_id' => 2, 'email' => '*****@*****.**']);
     $this->insert(WarehouseOpeninghours::tableName(), ['warehouse_id' => 2, 'monday' => 1, 'tuesday' => 1, 'wednesday' => 1, 'thursday' => 1, 'friday' => 0, 'saturday' => 0, 'sunday' => 1, 'all_day' => 0, 'opens' => '9:00', 'closes' => '22:00', 'break_from' => '', 'break_to' => '']);
     $this->batchInsert(Object::tableName(), ['name', 'object_class', 'object_table_name', 'column_properties_table_name', 'eav_table_name', 'categories_table_name', 'link_slug_category', 'link_slug_static_value', 'object_slug_attribute'], [['Property', Property::className(), Yii::$app->db->schema->getRawTableName(Property::tableName()), Yii::$app->db->schema->getRawTableName('{{%property_property}}'), Yii::$app->db->schema->getRawTableName('{{%property_eav}}'), Yii::$app->db->schema->getRawTableName('{{%property_category}}'), Yii::$app->db->schema->getRawTableName('{{%property_category_full_slug}}'), Yii::$app->db->schema->getRawTableName('{{%property_static_value_category}}'), 'slug'], ['PropertyStaticValues', PropertyStaticValues::className(), Yii::$app->db->schema->getRawTableName(PropertyStaticValues::tableName()), Yii::$app->db->schema->getRawTableName('{{%property_static_values_properties}}'), Yii::$app->db->schema->getRawTableName('{{%property_static_values_eav}}'), Yii::$app->db->schema->getRawTableName('{{%property_static_values_category}}'), Yii::$app->db->schema->getRawTableName('{{%property_static_values_category_full_slug}}'), Yii::$app->db->schema->getRawTableName('{{%property_static_values_static_value_category}}'), 'slug']]);
     $clearTask = new Task();
     $clearTask->setAttributes(['action' => 'background/tasks/clear-old-notifications', 'type' => Task::TYPE_REPEAT, 'initiator' => 1, 'name' => 'Clear old notify messages', 'cron_expression' => '*/1 * * * *', 'status' => 'ACTIVE']);
     $clearTask->save();
     $spamTask = new Task();
     $spamTask->setAttributes(['action' => 'submissions/mark-spam', 'type' => Task::TYPE_REPEAT, 'initiator' => 1, 'name' => 'Mark spam submissions as deleted', 'cron_expression' => '* * */1 * *', 'status' => 'ACTIVE']);
     $spamTask->save();
     $clearTask = new Task();
     $clearTask->setAttributes(['action' => 'submissions/clear-deleted', 'type' => Task::TYPE_REPEAT, 'initiator' => 1, 'name' => 'Clear deleted submissions', 'cron_expression' => '* * */3 * *', 'status' => 'ACTIVE']);
     $clearTask->save();
     $this->batchInsert(SpamChecker::tableName(), ['behavior', 'name', 'author_field', 'content_field'], [['app\\behaviors\\spamchecker\\AkismetSpamChecker', 'Akismet', 'comment_author', 'comment_content']]);
     $this->insert(ThumbnailSize::tableName(), ['width' => 80, 'height' => 80]);
     $this->insert(Task::tableName(), ['action' => 'images/check-broken', 'type' => Task::TYPE_REPEAT, 'initiator' => 1, 'name' => 'Check broken images', 'cron_expression' => '* */1 * * *']);
     $this->insert(ContentDecorator::tableName(), ['added_by_ext' => 'core', 'post_decorator' => 0, 'class_name' => 'app\\modules\\core\\decorators\\ContentBlock']);
     $this->insert(Events::tableName(), ['owner_class_name' => 'app\\modules\\shop\\ShopModule', 'event_name' => 'product_page_showed', 'event_class_name' => 'app\\modules\\shop\\events\\ProductPageShowed', 'event_description' => 'Product page is showed to user', 'documentation_link' => '']);
     $this->insert(Events::tableName(), ['owner_class_name' => 'app\\modules\\shop\\ShopModule', 'event_name' => 'product_showed_in_list', 'event_class_name' => 'app\\modules\\shop\\events\\ProductShowedInList', 'event_description' => 'Product is showed in product listing(shop/product/list)', 'documentation_link' => '']);
     $this->insert(Events::tableName(), ['owner_class_name' => 'app\\modules\\shop\\ShopModule', 'event_name' => 'product_category_listed', 'event_class_name' => 'app\\modules\\shop\\events\\ProductCategoryListed', 'event_description' => 'Category is listed by shop/product/list as last_category_id.', 'documentation_link' => '']);
     $this->insert(EventHandlers::tableName(), ['event_id' => 1, 'sort_order' => 1, 'handler_class_name' => 'app\\modules\\shop\\helpers\\LastViewedProducts', 'handler_function_name' => 'handleProductShowed', 'non_deletable' => 1, 'triggering_type' => EventTriggeringHelper::TYPE_APPLICATION]);
     $this->insert(ExtensionTypes::tableName(), ['name' => 'Theme']);
     $this->insert(ExtensionTypes::tableName(), ['name' => 'Module']);
     $this->insert(ExtensionTypes::tableName(), ['name' => 'Frontend widget']);
     $this->insert(ExtensionTypes::tableName(), ['name' => 'Dashboard widget']);
     $this->insert(ExtensionTypes::tableName(), ['name' => 'Backend input widget']);
     $this->batchInsert(DiscountType::tableName(), ['name', 'class', 'checking_class', 'add_view'], [['Discount Code', 'app\\modules\\shop\\models\\DiscountCode', 'Order', '@app/modules/shop/views/backend-discount/_discount_code'], ['Category Discount', 'app\\modules\\shop\\models\\CategoryDiscount', 'OrderItem', '@app/modules/shop/views/backend-discount/_category_discount'], ['User Discount', 'app\\modules\\shop\\models\\UserDiscount', 'Order', '@app/modules/shop/views/backend-discount/_user_discount'], ['Order Discount', 'app\\modules\\shop\\models\\OrderDiscount', 'Order', '@app/modules/shop/views/backend-discount/_order_discount'], ['Product Discount', 'app\\modules\\shop\\models\\ProductDiscount', 'OrderItem', '@app/modules/shop/views/backend-discount/_product_discount']]);
     $this->batchInsert(SpecialPriceList::tableName(), ['object_id', 'class', 'sort_order', 'type', 'handler'], [[\app\models\Object::getForClass(\app\modules\shop\models\Product::className())->id, 'app\\modules\\shop\\helpers\\PriceHandlers', 5, 'core', 'getCurrencyPriceProduct'], [\app\models\Object::getForClass(\app\modules\shop\models\Order::className())->id, 'app\\modules\\shop\\helpers\\PriceHandlers', 10, 'delivery', 'getDeliveryPriceOrder'], [\app\models\Object::getForClass(\app\modules\shop\models\Product::className())->id, 'app\\modules\\shop\\helpers\\PriceHandlers', 15, 'discount', 'getDiscountPriceProduct'], [\app\models\Object::getForClass(\app\modules\shop\models\Order::className())->id, 'app\\modules\\shop\\helpers\\PriceHandlers', 20, 'discount', 'getDiscountPriceOrder']]);
     $this->insert(Object::tableName(), ['name' => 'Customer', 'object_class' => 'app\\modules\\shop\\models\\Customer', 'object_table_name' => 'customer', 'column_properties_table_name' => 'customer_property', 'eav_table_name' => 'customer_eav', 'categories_table_name' => 'customer_category', 'link_slug_category' => 'customer_category_slug', 'link_slug_static_value' => 'customer_slug_static', 'object_slug_attribute' => 'slug']);
     $this->insert(Object::tableName(), ['name' => 'Contragent', 'object_class' => 'app\\modules\\shop\\models\\Contragent', 'object_table_name' => 'contragent', 'column_properties_table_name' => 'contragent_property', 'eav_table_name' => 'contragent_eav', 'categories_table_name' => 'contragent_category', 'link_slug_category' => 'contragent_category_slug', 'link_slug_static_value' => 'contragent_slug_static', 'object_slug_attribute' => 'slug']);
     $this->insert(Object::tableName(), ['name' => 'OrderDeliveryInformation', 'object_class' => 'app\\modules\\shop\\models\\OrderDeliveryInformation', 'object_table_name' => 'order_delivery_information', 'column_properties_table_name' => 'order_delivery_information_property', 'eav_table_name' => 'order_delivery_information_eav', 'categories_table_name' => 'order_delivery_information_category', 'link_slug_category' => 'order_delivery_information_category_slug', 'link_slug_static_value' => 'order_delivery_information_slug_static', 'object_slug_attribute' => 'slug']);
     $this->insert(Events::tableName(), ['owner_class_name' => 'app\\modules\\shop\\ShopModule', 'event_name' => 'order_stage_customer', 'event_class_name' => 'app\\modules\\shop\\events\\StageCustomer', 'selector_prefix' => '', 'event_description' => '', 'documentation_link' => '']);
     $eventId = $this->db->lastInsertID;
     $this->insert(EventHandlers::tableName(), ['event_id' => $eventId, 'sort_order' => 0, 'handler_class_name' => 'app\\modules\\shop\\helpers\\BaseOrderStageHandlers', 'handler_function_name' => 'handleStageCustomer', 'is_active' => 1, 'non_deletable' => 0, 'triggering_type' => 'application_trigger']);
     $this->insert(Events::tableName(), ['owner_class_name' => 'app\\modules\\shop\\ShopModule', 'event_name' => 'order_stage_delivery', 'event_class_name' => 'app\\modules\\shop\\events\\StageDelivery', 'selector_prefix' => '', 'event_description' => '', 'documentation_link' => '']);
     $eventId = $this->db->lastInsertID;
     $this->insert(EventHandlers::tableName(), ['event_id' => $eventId, 'sort_order' => 0, 'handler_class_name' => 'app\\modules\\shop\\helpers\\BaseOrderStageHandlers', 'handler_function_name' => 'handleStageDelivery', 'is_active' => 1, 'non_deletable' => 0, 'triggering_type' => 'application_trigger']);
     $this->insert(Events::tableName(), ['owner_class_name' => 'app\\modules\\shop\\ShopModule', 'event_name' => 'order_stage_payment', 'event_class_name' => 'app\\modules\\shop\\events\\StagePayment', 'selector_prefix' => '', 'event_description' => '', 'documentation_link' => '']);
     $eventId = $this->db->lastInsertID;
     $this->insert(EventHandlers::tableName(), ['event_id' => $eventId, 'sort_order' => 0, 'handler_class_name' => 'app\\modules\\shop\\helpers\\BaseOrderStageHandlers', 'handler_function_name' => 'handleStagePayment', 'is_active' => 1, 'non_deletable' => 0, 'triggering_type' => 'application_trigger']);
     $this->insert(Events::tableName(), ['owner_class_name' => 'app\\modules\\shop\\ShopModule', 'event_name' => 'order_stage_payment_pay', 'event_class_name' => 'app\\modules\\shop\\events\\StagePaymentPay', 'selector_prefix' => '', 'event_description' => '', 'documentation_link' => '']);
     $eventId = $this->db->lastInsertID;
     $this->insert(EventHandlers::tableName(), ['event_id' => $eventId, 'sort_order' => 0, 'handler_class_name' => 'app\\modules\\shop\\helpers\\BaseOrderStageHandlers', 'handler_function_name' => 'handleStagePaymentPay', 'is_active' => 1, 'non_deletable' => 0, 'triggering_type' => 'application_trigger']);
     $this->insert(Events::tableName(), ['owner_class_name' => 'app\\modules\\shop\\ShopModule', 'event_name' => 'order_stageleaf_customer', 'event_class_name' => 'app\\modules\\shop\\events\\StageLeafCustomer', 'selector_prefix' => '', 'event_description' => '', 'documentation_link' => '']);
     $eventId = $this->db->lastInsertID;
     $this->insert(EventHandlers::tableName(), ['event_id' => $eventId, 'sort_order' => 0, 'handler_class_name' => 'app\\modules\\shop\\helpers\\BaseOrderStageHandlers', 'handler_function_name' => 'handleCustomer', 'is_active' => 1, 'non_deletable' => 0, 'triggering_type' => 'application_trigger']);
     $this->insert(Events::tableName(), ['owner_class_name' => 'app\\modules\\shop\\ShopModule', 'event_name' => 'order_stageleaf_payment_choose', 'event_class_name' => 'app\\modules\\shop\\events\\StageLeafPayment', 'selector_prefix' => '', 'event_description' => '', 'documentation_link' => '']);
     $eventId = $this->db->lastInsertID;
     $this->insert(EventHandlers::tableName(), ['event_id' => $eventId, 'sort_order' => 0, 'handler_class_name' => 'app\\modules\\shop\\helpers\\BaseOrderStageHandlers', 'handler_function_name' => 'handlePayment', 'is_active' => 1, 'non_deletable' => 0, 'triggering_type' => 'application_trigger']);
     $this->insert(Events::tableName(), ['owner_class_name' => 'app\\modules\\shop\\ShopModule', 'event_name' => 'order_stageleaf_delivery_choose', 'event_class_name' => 'app\\modules\\shop\\events\\StageLeafDelivery', 'selector_prefix' => '', 'event_description' => '', 'documentation_link' => '']);
     $eventId = $this->db->lastInsertID;
     $this->insert(EventHandlers::tableName(), ['event_id' => $eventId, 'sort_order' => 0, 'handler_class_name' => 'app\\modules\\shop\\helpers\\BaseOrderStageHandlers', 'handler_function_name' => 'handleDelivery', 'is_active' => 1, 'non_deletable' => 0, 'triggering_type' => 'application_trigger']);
     $this->insert(Events::tableName(), ['owner_class_name' => 'app\\modules\\shop\\ShopModule', 'event_name' => 'order_stageleaf_payment_pay', 'event_class_name' => 'app\\modules\\shop\\events\\StageLeafPaymentPay', 'selector_prefix' => '', 'event_description' => '', 'documentation_link' => '']);
     $eventId = $this->db->lastInsertID;
     $this->insert(EventHandlers::tableName(), ['event_id' => $eventId, 'sort_order' => 0, 'handler_class_name' => 'app\\modules\\shop\\helpers\\BaseOrderStageHandlers', 'handler_function_name' => 'handlePaymentPay', 'is_active' => 1, 'non_deletable' => 0, 'triggering_type' => 'application_trigger']);
     $this->insert(Events::tableName(), ['owner_class_name' => 'app\\modules\\shop\\ShopModule', 'event_name' => 'order_stageleaf_manager_process', 'event_class_name' => 'app\\modules\\shop\\events\\StageLeafManagerProcess', 'selector_prefix' => '', 'event_description' => '', 'documentation_link' => '']);
     $eventId = $this->db->lastInsertID;
     $this->insert(EventHandlers::tableName(), ['event_id' => $eventId, 'sort_order' => 0, 'handler_class_name' => 'app\\modules\\shop\\helpers\\BaseOrderStageHandlers', 'handler_function_name' => 'handleManagerProcess', 'is_active' => 1, 'non_deletable' => 0, 'triggering_type' => 'application_trigger']);
     $this->insert(Events::tableName(), ['owner_class_name' => 'app\\modules\\shop\\ShopModule', 'event_name' => 'order_calculate', 'event_class_name' => 'app\\modules\\shop\\events\\OrderCalculateEvent', 'selector_prefix' => '', 'event_description' => '', 'documentation_link' => '']);
     $eventId = $this->db->lastInsertID;
     $this->insert(EventHandlers::tableName(), ['event_id' => $eventId, 'sort_order' => 0, 'handler_class_name' => 'app\\modules\\shop\\helpers\\PriceHandlers', 'handler_function_name' => 'handleSaveDiscounts', 'is_active' => 1, 'non_deletable' => 0, 'triggering_type' => 'application_trigger']);
     $this->insert(EventHandlers::tableName(), ['event_id' => $eventId, 'sort_order' => -5, 'handler_class_name' => 'app\\modules\\shop\\helpers\\PriceHandlers', 'handler_function_name' => 'handleSaveDelivery', 'is_active' => 1, 'non_deletable' => 0, 'triggering_type' => 'application_trigger']);
     $this->insert(OrderStage::tableName(), ['name' => 'customer', 'name_frontend' => Yii::t('app', 'Your information'), 'name_short' => 'customer', 'is_initial' => 1, 'is_buyer_stage' => 1, 'become_non_temporary' => 0, 'is_in_cart' => 1, 'immutable_by_user' => 0, 'immutable_by_manager' => 0, 'immutable_by_assigned' => 0, 'reach_goal_ym' => '', 'reach_goal_ga' => '', 'event_name' => 'order_stage_customer', 'view' => '@app/modules/shop/views/cart/stages/name.php']);
     $stageCustomer = $this->db->lastInsertID;
     $this->insert(OrderStage::tableName(), ['name' => 'delivery', 'name_frontend' => Yii::t('app', 'Delivery'), 'name_short' => 'delivery', 'is_initial' => 0, 'is_buyer_stage' => 1, 'become_non_temporary' => 0, 'is_in_cart' => 1, 'immutable_by_user' => 0, 'immutable_by_manager' => 0, 'immutable_by_assigned' => 0, 'reach_goal_ym' => '', 'reach_goal_ga' => '', 'event_name' => 'order_stage_delivery', 'view' => '@app/modules/shop/views/cart/stages/delivery.php']);
     $stageDelivery = $this->db->lastInsertID;
     $this->insert(OrderStage::tableName(), ['name' => 'payment', 'name_frontend' => Yii::t('app', 'Payment method selection'), 'name_short' => 'payment', 'is_initial' => 0, 'is_buyer_stage' => 1, 'become_non_temporary' => 0, 'is_in_cart' => 1, 'immutable_by_user' => 0, 'immutable_by_manager' => 0, 'immutable_by_assigned' => 0, 'reach_goal_ym' => '', 'reach_goal_ga' => '', 'event_name' => 'order_stage_payment', 'view' => '@app/modules/shop/views/cart/stages/payment.php']);
     $stagePayment = $this->db->lastInsertID;
     $this->insert(OrderStage::tableName(), ['name' => 'payment pay', 'name_frontend' => Yii::t('app', 'Payment'), 'name_short' => 'payment pay', 'is_initial' => 0, 'is_buyer_stage' => 0, 'become_non_temporary' => 1, 'is_in_cart' => 0, 'immutable_by_user' => 0, 'immutable_by_manager' => 0, 'immutable_by_assigned' => 0, 'reach_goal_ym' => '', 'reach_goal_ga' => '', 'event_name' => 'order_stage_payment_pay', 'view' => '@app/modules/shop/views/cart/stages/pay.php']);
     $stagePaymentPay = $this->db->lastInsertID;
     $this->insert(OrderStageLeaf::tableName(), ['stage_from_id' => $stageCustomer, 'stage_to_id' => $stageDelivery, 'sort_order' => 0, 'button_label' => Yii::t('app', 'Delivery method selection'), 'button_css_class' => 'btn btn-primary', 'notify_manager' => 0, 'notify_new_assigned_user' => 0, 'role_assignment_policy' => 'random', 'event_name' => 'order_stageleaf_customer']);
     $this->insert(OrderStageLeaf::tableName(), ['stage_from_id' => $stageDelivery, 'stage_to_id' => $stagePayment, 'sort_order' => 0, 'button_label' => Yii::t('app', 'Payment method selection'), 'button_css_class' => 'btn btn-primary', 'notify_manager' => 0, 'notify_new_assigned_user' => 0, 'role_assignment_policy' => 'random', 'event_name' => 'order_stageleaf_delivery_choose']);
     $this->insert(OrderStageLeaf::tableName(), ['stage_from_id' => $stagePayment, 'stage_to_id' => $stagePaymentPay, 'sort_order' => 0, 'button_label' => Yii::t('app', 'Go to payment'), 'button_css_class' => 'btn btn-success', 'notify_manager' => 1, 'assign_to_user_id' => 0, 'assign_to_role' => null, 'notify_new_assigned_user' => 0, 'role_assignment_policy' => 'random', 'event_name' => 'order_stageleaf_payment_choose']);
     $this->insert(OrderStage::tableName(), ['name' => 'final', 'name_frontend' => Yii::t('app', 'Order complete'), 'name_short' => 'final', 'is_initial' => 0, 'is_buyer_stage' => 0, 'become_non_temporary' => 0, 'is_in_cart' => 0, 'immutable_by_user' => 1, 'immutable_by_manager' => 1, 'immutable_by_assigned' => 1, 'reach_goal_ym' => '', 'reach_goal_ga' => '', 'event_name' => 'order_stage_final', 'view' => '']);
     $stage = $this->db->lastInsertID;
     $this->insert(OrderStageLeaf::tableName(), ['stage_from_id' => $stage, 'stage_to_id' => $stagePaymentPay, 'sort_order' => 0, 'button_label' => Yii::t('app', 'Order complete'), 'button_css_class' => 'btn btn-primary', 'notify_manager' => 0, 'notify_new_assigned_user' => 0, 'role_assignment_policy' => 'random', 'event_name' => 'order_stage_leaf_final']);
     $this->insert(Measure::tableName(), ['name' => Yii::t('app', 'Pieces'), 'symbol' => Yii::t('app', 'pcs'), 'nominal' => 1]);
     $this->batchInsert(Configurable::tableName(), ['module', 'sort_order', 'section_name', 'display_in_config'], [['core', '1', 'Core', '1'], ['DefaultTheme', '2', 'Default Theme', '1'], ['shop', '3', 'Shop', '1'], ['user', '4', 'Users & Roles', '1'], ['page', '5', 'Pages', '1'], ['image', '6', 'Images', '1'], ['seo', '7', 'SEO', '1'], ['backend', '8', 'Backend', '1'], ['review', '9', 'Reviews', '1'], ['data', '10', 'Data import/export', '1'], ['background', 17, 'Background tasks', 1]]);
     $this->insert(\app\modules\seo\models\Robots::tableName(), ['key' => 'robots.txt', 'value' => "User-agent: *\nDisallow: /cabinet\n"]);
     $cacheLifetime = 86400;
     $baseParts = [['name' => Yii::t('app', 'Pre-Header'), 'key' => 'pre-header', 'multiple_widgets' => 1, 'cache_lifetime' => $cacheLifetime, 'cache_tags' => '\\app\\widgets\\navigation\\models\\Navigation'], ['name' => Yii::t('app', 'Header'), 'key' => 'header', 'multiple_widgets' => 0, 'is_cacheable' => 0, 'cache_tags' => '\\app\\widgets\\navigation\\models\\Navigation'], ['name' => Yii::t('app', 'Post-Header'), 'key' => 'post-header', 'multiple_widgets' => 1, 'cache_lifetime' => $cacheLifetime, 'cache_tags' => '\\app\\widgets\\navigation\\models\\Navigation'], ['name' => Yii::t('app', 'Before content'), 'key' => 'before-content', 'multiple_widgets' => 1], ['name' => Yii::t('app', 'Left sidebar'), 'key' => 'left-sidebar', 'multiple_widgets' => 1, 'is_cacheable' => 0], ['name' => Yii::t('app', 'Before inner-content'), 'key' => 'before-inner-content', 'multiple_widgets' => 1, 'is_cacheable' => 0], ['name' => Yii::t('app', 'After inner-content'), 'key' => 'after-inner-content', 'multiple_widgets' => 1, 'is_cacheable' => 0], ['name' => Yii::t('app', 'Right sidebar'), 'key' => 'right-sidebar', 'multiple_widgets' => 1, 'is_cacheable' => 0], ['name' => Yii::t('app', 'Pre-footer'), 'key' => 'pre-footer', 'multiple_widgets' => 1, 'cache_lifetime' => $cacheLifetime], ['name' => Yii::t('app', 'Footer'), 'key' => 'footer', 'multiple_widgets' => 1, 'cache_lifetime' => $cacheLifetime], ['name' => Yii::t('app', 'Post-footer'), 'key' => 'post-footer', 'multiple_widgets' => 1, 'cache_lifetime' => $cacheLifetime]];
     $this->bulkInsert(ThemeParts::tableName(), $baseParts);
     $baseWidgets = [['name' => Yii::t('app', '1-row header with logo, nav and popup cart'), 'widget' => 'app\\extensions\\DefaultTheme\\widgets\\OneRowHeaderWithCart\\Widget', 'cache_lifetime' => $cacheLifetime, 'cache_vary_by_session' => 1, 'configuration_json' => '{}', 'configuration_model' => 'app\\extensions\\DefaultTheme\\widgets\\OneRowHeaderWithCart\\ConfigurationModel', 'configuration_view' => '@app/extensions/DefaultTheme/widgets/OneRowHeaderWithCart/views/_config.php'], ['name' => Yii::t('app', '1-row header with logo, nav'), 'widget' => 'app\\extensions\\DefaultTheme\\widgets\\OneRowHeader\\Widget', 'cache_lifetime' => $cacheLifetime, 'configuration_json' => '{}', 'configuration_model' => 'app\\extensions\\DefaultTheme\\widgets\\OneRowHeader\\ConfigurationModel', 'configuration_view' => '@app/extensions/DefaultTheme/widgets/OneRowHeader/views/_config.php'], ['name' => Yii::t('app', 'Slider'), 'widget' => 'app\\extensions\\DefaultTheme\\widgets\\Slider\\Widget', 'cache_lifetime' => $cacheLifetime, 'configuration_json' => '{}', 'configuration_model' => 'app\\extensions\\DefaultTheme\\widgets\\Slider\\ConfigurationModel', 'configuration_view' => '@app/extensions/DefaultTheme/widgets/Slider/views/_config.php']];
     $this->bulkInsert(ThemeWidgets::tableName(), $baseWidgets);
     $applying = [['widget_id' => 1, 'part_id' => 2], ['widget_id' => 2, 'part_id' => 2], ['widget_id' => 3, 'part_id' => 4], ['widget_id' => 3, 'part_id' => 6]];
     $this->bulkInsert(ThemeWidgetApplying::tableName(), $applying);
     $variations = [['name' => Yii::t('app', 'Main page'), 'by_url' => '/'], ['name' => Yii::t('app', 'Non main page'), 'by_url' => '/*'], ['name' => Yii::t('app', 'Product listing'), 'by_route' => 'shop/product/list'], ['name' => Yii::t('app', 'Product page(show)'), 'by_route' => 'shop/product/show'], ['name' => Yii::t('app', 'Content page listing'), 'by_route' => 'page/page/list'], ['name' => Yii::t('app', 'Content page(show)'), 'by_route' => 'page/page/show']];
     $this->bulkInsert(ThemeVariation::tableName(), $variations);
     $activeWidgets = [['widget_id' => 1, 'part_id' => 2, 'variation_id' => 2], ['widget_id' => 1, 'part_id' => 2, 'variation_id' => 1], ['widget_id' => 3, 'part_id' => 4, 'variation_id' => 1], ['widget_id' => 3, 'part_id' => 6, 'variation_id' => 3]];
     $this->bulkInsert(ThemeActiveWidgets::tableName(), $activeWidgets);
     $this->insert('{{%theme_widgets}}', ['name' => Yii::t('app', 'Categories list'), 'widget' => 'app\\extensions\\DefaultTheme\\widgets\\CategoriesList\\Widget', 'configuration_model' => 'app\\extensions\\DefaultTheme\\widgets\\CategoriesList\\ConfigurationModel', 'configuration_view' => '@app/extensions/DefaultTheme/widgets/CategoriesList/views/_config.php', 'configuration_json' => '{}', 'is_cacheable' => 0, 'cache_tags' => \app\modules\shop\models\Category::className()]);
     $categoriesListWidgetId = $this->db->lastInsertID;
     $this->insert(ThemeWidgets::tableName(), ['name' => Yii::t('app', 'Filter widget'), 'widget' => 'app\\extensions\\DefaultTheme\\widgets\\FilterSets\\Widget', 'configuration_model' => 'app\\extensions\\DefaultTheme\\widgets\\FilterSets\\ConfigurationModel', 'configuration_view' => '@app/extensions/DefaultTheme/widgets/FilterSets/views/_config.php', 'configuration_json' => '{}', 'is_cacheable' => 0, 'cache_tags' => '']);
     $filterSetsWidget = $this->db->lastInsertID;
     $this->insert(ThemeWidgets::tableName(), ['name' => Yii::t('app', 'Pages list'), 'widget' => 'app\\extensions\\DefaultTheme\\widgets\\PagesList\\Widget', 'configuration_model' => 'app\\extensions\\DefaultTheme\\widgets\\PagesList\\ConfigurationModel', 'configuration_view' => '@app/extensions/DefaultTheme/widgets/PagesList/views/_config.php', 'configuration_json' => '{}', 'is_cacheable' => 1, 'cache_lifetime' => 86400, 'cache_tags' => Page::className()]);
     $pagesList = $this->db->lastInsertID;
     $this->insert(ThemeWidgets::tableName(), ['name' => Yii::t('app', 'Content block'), 'widget' => 'app\\extensions\\DefaultTheme\\widgets\\ContentBlock\\Widget', 'configuration_model' => 'app\\extensions\\DefaultTheme\\widgets\\ContentBlock\\ConfigurationModel', 'configuration_view' => '@app/extensions/DefaultTheme/widgets/ContentBlock/views/_config.php', 'configuration_json' => '{}', 'is_cacheable' => 1, 'cache_lifetime' => 86400, 'cache_tags' => Page::className()]);
     $contentBlock = $this->db->lastInsertID;
     $allBlocks = [$categoriesListWidgetId, $filterSetsWidget, $pagesList, $contentBlock];
     foreach ($allBlocks as $widget_id) {
         // left sidebar
         $this->insert('{{%theme_widget_applying}}', ['widget_id' => $widget_id, 'part_id' => 5]);
         // right sidebar
         $this->insert('{{%theme_widget_applying}}', ['widget_id' => $widget_id, 'part_id' => 8]);
     }
     $this->insert(Events::tableName(), ['owner_class_name' => 'app\\modules\\shop\\ShopModule', 'event_name' => 'order_stage_final', 'event_class_name' => 'app\\modules\\shop\\events\\StageFinal', 'selector_prefix' => '', 'event_description' => '', 'documentation_link' => '']);
     $eventId = $this->db->lastInsertID;
     $this->insert(EventHandlers::tableName(), ['event_id' => $eventId, 'sort_order' => 0, 'handler_class_name' => 'app\\modules\\shop\\helpers\\BaseOrderStageHandlers', 'handler_function_name' => 'handleStageFinal', 'is_active' => 1, 'non_deletable' => 1, 'triggering_type' => 'application_trigger']);
     $this->insert(Events::tableName(), ['owner_class_name' => 'app\\modules\\shop\\ShopModule', 'event_name' => 'order_stage_leaf_final', 'event_class_name' => 'app\\modules\\shop\\events\\StageLeafFinal', 'selector_prefix' => '', 'event_description' => '', 'documentation_link' => '']);
     $eventId = $this->db->lastInsertID;
     $this->insert(EventHandlers::tableName(), ['event_id' => $eventId, 'sort_order' => 0, 'handler_class_name' => 'app\\modules\\shop\\helpers\\BaseOrderStageHandlers', 'handler_function_name' => 'handleFinal', 'is_active' => 1, 'non_deletable' => 1, 'triggering_type' => 'application_trigger']);
     //
     $propertyHandler = PropertyHandler::findOne(['name' => 'Text']);
     $form = new \app\models\Form();
     $form->name = 'Review form';
     $form->email_notification_addresses = '';
     $form->email_notification_view = '@app/modules/review/views/review-email-template.php';
     $form->save(false, ['name', 'email_notification_addresses', 'email_notification_view']);
     $propertyGroup = new PropertyGroup();
     $propertyGroup->attributes = ['object_id' => $form->object->id, 'name' => 'Review form additional properties', 'hidden_group_title' => 1];
     $propertyGroup->save(true, ['object_id', 'name', 'hidden_group_title']);
     $nameProperty = new Property();
     $nameProperty->attributes = ['property_group_id' => $propertyGroup->id, 'name' => 'Name', 'key' => 'name', 'property_handler_id' => $propertyHandler->id, 'handler_additional_params' => '{}', 'is_eav' => 1];
     $nameProperty->save(true, ['property_group_id', 'name', 'key', 'property_handler_id', 'is_eav', 'handler_additional_params']);
     $phoneProperty = new Property();
     $phoneProperty->attributes = ['property_group_id' => $propertyGroup->id, 'name' => 'Phone', 'key' => 'phone', 'property_handler_id' => $propertyHandler->id, 'handler_additional_params' => '{}', 'is_eav' => 1];
     $phoneProperty->save(true, ['property_group_id', 'name', 'key', 'property_handler_id', 'is_eav', 'handler_additional_params']);
     $objectPropertyGroup = new ObjectPropertyGroup();
     $objectPropertyGroup->attributes = ['object_id' => $form->object->id, 'object_model_id' => $form->id, 'property_group_id' => $propertyGroup->id];
     $objectPropertyGroup->save(true, ['object_id', 'object_model_id', 'property_group_id']);
 }
Esempio n. 22
0
 public function getPossibleSelections()
 {
     $data = ['propertyIds' => [], 'propertyStaticValueIds' => []];
     if ($this->onlyAvailableFilters) {
         Yii::beginProfile("onlyAvailableFilters");
         $object = Object::findById($this->objectId);
         if (!is_null($object) && isset($this->currentSelections['last_category_id'])) {
             $cacheKey = 'FilterWidget: ' . $object->id . ':' . $this->currentSelections['last_category_id'] . ':' . Json::encode($this->currentSelections['properties']);
             $data = Yii::$app->cache->get($cacheKey);
             if ($data === false) {
                 $data = [];
                 Yii::beginProfile("ObjectIds for this category");
                 $query = new Query();
                 $query = $query->select($object->categories_table_name . '.object_model_id')->distinct()->from($object->categories_table_name)->join("JOIN", Product::tableName(), sprintf("%s.`id` = %s.`object_model_id`", Product::tableName(), $object->categories_table_name))->andWhere([Product::tableName() . ".`active`" => 1])->andWhere(['category_id' => $this->currentSelections['last_category_id']]);
                 if (count($this->currentSelections['properties']) > 0) {
                     Yii::beginProfile("Apply currency selections(properties)");
                     foreach ($this->currentSelections['properties'] as $property_id => $values) {
                         $joinTableName = 'OSVJoinTable' . $property_id;
                         $query->join('JOIN', ObjectStaticValues::tableName() . ' ' . $joinTableName, $joinTableName . '.object_id = :objectId AND ' . $joinTableName . '.object_model_id = ' . $object->categories_table_name . '.object_model_id  ', [':objectId' => $object->id]);
                         $query->andWhere(['in', '`' . $joinTableName . '`.`property_static_value_id`', $values]);
                     }
                     Yii::endProfile("Apply currency selections(properties)");
                 }
                 Yii::endProfile("ObjectIds for this category");
                 $ids = array_map('intval', $query->column());
                 $query = null;
                 Yii::beginProfile("all PSV ids");
                 $data['propertyStaticValueIds'] = [];
                 if (count($ids) !== 0) {
                     $q4psv = (new Query())->select('property_static_value_id')->from(ObjectStaticValues::tableName())->distinct()->where(['object_id' => $object->id])->andWhere('object_model_id in (' . implode(',', $ids) . ')');
                     $data['propertyStaticValueIds'] = array_map('intval', $q4psv->column());
                 }
                 Yii::endProfile("all PSV ids");
                 $ids = null;
                 Yii::beginProfile("Property ids from PSV ids");
                 $data['propertyIds'] = [];
                 if (count($data['propertyStaticValueIds']) !== 0) {
                     $data['propertyIds'] = PropertyStaticValues::find()->select('property_id')->distinct()->where(['dont_filter' => 0])->andWhere('id IN (' . implode(',', $data['propertyStaticValueIds']) . ')')->asArray()->column();
                 }
                 Yii::endProfile("Property ids from PSV ids");
                 Yii::$app->cache->set($cacheKey, $data, 86400, new TagDependency(['tags' => [\devgroup\TagDependencyHelper\ActiveRecordHelper::getCommonTag($object->object_class)]]));
                 $object = null;
             }
         }
         Yii::endProfile("onlyAvailableFilters");
     }
     $this->possibleSelections = [];
     $groups = PropertyGroup::getForObjectId($this->objectId);
     foreach ($groups as $group) {
         if ($this->onlyGroupsIds !== null) {
             if (in_array($group->id, $this->onlyGroupsIds) === false) {
                 // skip this group
                 continue;
             }
         }
         if ($group->is_internal) {
             continue;
         }
         $this->possibleSelections[$group->id] = ['group' => $group, 'selections' => [], 'static_selections' => [], 'dynamic_selections' => []];
         $props = Property::getForGroupId($group->id);
         foreach ($props as $p) {
             if ($this->onlyAvailableFilters && !in_array($p->id, $data['propertyIds'])) {
                 if ($this->disableInsteadOfHide === false) {
                     continue;
                 }
             }
             if ($p->dont_filter) {
                 continue;
             }
             if ($p->has_static_values) {
                 $propertyStaticValues = PropertyStaticValues::getValuesForPropertyId($p->id);
                 foreach ($propertyStaticValues as $key => $propertyStaticValue) {
                     if ($propertyStaticValue['dont_filter']) {
                         unset($propertyStaticValues[$key]);
                     }
                 }
                 if ($this->onlyAvailableFilters) {
                     foreach ($propertyStaticValues as $key => $propertyStaticValue) {
                         if (!in_array($propertyStaticValue['id'], $data['propertyStaticValueIds'])) {
                             if ($this->disableInsteadOfHide === true) {
                                 $this->disabled_ids[] = $propertyStaticValue['id'];
                             } else {
                                 unset($propertyStaticValues[$key]);
                             }
                         }
                     }
                 }
                 $this->possibleSelections[$group->id]['static_selections'][$p->id] = $propertyStaticValues;
             } elseif ($p->is_column_type_stored && $p->value_type == 'NUMBER') {
                 $this->possibleSelections[$group->id]['dynamic_selections'][] = $p->id;
             }
         }
         if (count($this->possibleSelections[$group->id]) === 0) {
             unset($this->possibleSelections[$group->id]);
         }
     }
 }
 /**
  * @param Order $order
  * @param boolean $dummyObject Empty object, non saved to database
  * @return OrderDeliveryInformation|null
  * @throws \Exception
  */
 public static function createNewOrderDeliveryInformation(Order $order, $dummyObject = true)
 {
     /** @var OrderDeliveryInformation|HasProperties $model */
     $model = new static();
     $model->order_id = $order->id;
     $model->loadDefaultValues();
     $groups = PropertyGroup::getForObjectId($model->getObject()->id, true);
     $group = array_shift($groups);
     if (null !== $group) {
         $model->setPropertyGroup($group);
         $abstractModel = new AbstractModel();
         $abstractModel->setPropertiesModels(array_reduce($group->properties, function ($result, $item) {
             /** @var Property $item */
             $result[$item->key] = $item;
             return $result;
         }, []));
         $abstractModel->setAttributes(array_reduce($group->properties, function ($result, $item) use($model) {
             /** @var Property $item */
             $result[$item->key] = new PropertyValue([], $item->id, $model->getObject()->id, null);
             return $result;
         }, []));
         $abstractModel->setFormName('OrderDeliveryInformationNew');
         $model->setAbstractModel($abstractModel);
     }
     if (!$dummyObject) {
         $model->shipping_option_id = 0;
         if ($model->save()) {
             if (!empty($model->getPropertyGroup())) {
                 $model->getPropertyGroup()->appendToObjectModel($model);
             }
         } else {
             return null;
         }
     }
     return $model;
 }
        <div class="col-md-12">
            <?php 
        echo $form->field($model, 'file')->fileInput();
        ?>
        </div>
    </div>
    <div class="form-group row">
        <div class="col-md-12">
            <fieldset>
                <legend>
                    <?php 
        echo Yii::t('app', 'Add property groups to each new object: ');
        ?>
                </legend>
                <?php 
        echo $form->field($model, 'addPropertyGroups')->checkboxList(\yii\helpers\ArrayHelper::map(\app\models\PropertyGroup::getForObjectId($object->id), 'id', 'name'), ['item' => function ($index, $label, $name, $checked, $value) {
            $line = Html::beginTag('div', ['class' => 'checkbox']);
            $line .= Html::checkbox($name, $checked, ['value' => $value, 'label' => Html::encode($label)]);
            $line .= '</div>';
            return $line;
        }])->label('');
        ?>
            </fieldset>
        </div>
    </div>
    <?php 
    }
    ?>

    <?php 
    if (!$importMode) {
Esempio n. 25
0
 public function down()
 {
     $this->dropTable('{{%user_category}}');
     $this->dropTable('{{%user_eav}}');
     $this->dropTable('{{%user_property}}');
     $this->dropTable(UserService::tableName());
     $this->dropTable(User::tableName());
     $this->dropTable('{{%auth_assignment}}');
     $this->dropTable('{{%auth_item_child}}');
     $this->dropTable('{{%auth_item}}');
     $this->dropTable('{{%auth_rule}}');
     $this->dropTable(ErrorUrl::tableName());
     $this->dropTable(ErrorLog::tableName());
     $this->dropTable(Review::tableName());
     $this->dropTable(Notification::tableName());
     $this->dropTable('{{%submission_eav}}');
     $this->dropTable('{{%submission_category}}');
     $this->dropTable('{{%submission_property}}');
     $this->dropTable(Submission::tableName());
     $this->dropTable('{{%form_property}}');
     $this->dropTable('{{%form_eav}}');
     $this->dropTable(Form::tableName());
     $this->dropTable('{{%order_category}}');
     $this->dropTable('{{%order_eav}}');
     $this->dropTable('{{%order_property}}');
     $this->dropTable(PaymentType::tableName());
     $this->dropTable(ShippingOption::tableName());
     $this->dropTable(OrderChat::tableName());
     $this->dropTable(OrderTransaction::tableName());
     $this->dropTable(OrderItem::tableName());
     $this->dropTable(Order::tableName());
     $this->dropTable(SubscribeEmail::tableName());
     $this->dropTable(CategoryGroupRouteTemplates::tableName());
     $this->dropTable('{{%product_category}}');
     $this->dropTable('{{%property_category}}');
     $this->dropTable('{{%category_eav}}');
     $this->dropTable(Category::tableName());
     $this->dropTable(CategoryGroup::tableName());
     $this->dropTable('{{%page_eav}}');
     $this->dropTable('{{%page_category}}');
     $this->dropTable('{{%page_property}}');
     $this->dropTable(Page::tableName());
     $this->dropTable(ViewObject::tableName());
     $this->dropTable(View::tableName());
     $this->dropTable(Layout::tableName());
     $this->dropTable('{{%product_property}}');
     $this->dropTable(Product::tableName());
     $this->dropTable(Property::tableName());
     $this->dropTable(Route::tableName());
     $this->dropTable('{{%product_eav}}');
     $this->dropTable('{{%product_static_value_full_slug}}');
     $this->dropTable('{{%product_category_full_slug}}');
     $this->dropTable(PropertyStaticValues::tableName());
     $this->dropTable(PropertyHandler::tableName());
     $this->dropTable(PropertyGroup::tableName());
     $this->dropTable(ObjectStaticValues::tableName());
     $this->dropTable(ObjectPropertyGroup::tableName());
     $this->dropTable(Object::tableName());
     $this->dropTable(DynamicContent::tableName());
     $this->dropTable(Navigation::tableName());
     $this->dropTable(Image::tableName());
     $this->dropTable('{{%session}}');
     $this->dropTable(ApiService::tableName());
 }
Esempio n. 26
0
?>
            <?php 
BackendWidget::end();
?>
        </div>
    </div>
</div>
<?php 
echo $this->blocks['page-buttons'];
$form->end();
?>

<?php 
\yii\bootstrap\Modal::begin(['id' => 'custom-fields-modal', 'header' => Yii::t('app', 'Edit order properties')]);
$form = \kartik\widgets\ActiveForm::begin(['action' => ['update-order-properties', 'id' => $model->id]]);
foreach (\app\models\PropertyGroup::getForModel($model->object->id, $model->id) as $group) {
    ?>
    <?php 
    if ($group->hidden_group_title == 0) {
        ?>
        <h4><?php 
        echo $group->name;
        ?>
</h4>
    <?php 
    }
    ?>
    <?php 
    $properties = \app\models\Property::getForGroupId($group->id);
    ?>
    <?php 
Esempio n. 27
0
 public function actionAutocomplete($search = null, $id = null, $object_id = null)
 {
     /**
      * @todo Добавить отображение вложенности
      */
     $out = ['more' => false];
     if (!is_null($search)) {
         $query = new Query();
         $query->select(Property::tableName() . '.id, ' . Property::tableName() . '.name AS text')->from(Property::tableName())->andWhere(['like', Property::tableName() . '.name', $search])->limit(100);
         if (!is_null($object_id)) {
             $query->leftJoin(PropertyGroup::tableName(), PropertyGroup::tableName() . '.id = ' . Property::tableName() . '.property_group_id');
             $query->andWhere([PropertyGroup::tableName() . '.id' => $object_id]);
         }
         $command = $query->createCommand();
         $data = $command->queryAll();
         $out['results'] = array_values($data);
     } elseif ($id > 0) {
         $out['results'] = ['id' => $id, 'text' => Property::findOne($id)->name];
     } else {
         $out['results'] = ['id' => 0, 'text' => Yii::t('app', 'No matching records found')];
     }
     echo Json::encode($out);
 }
Esempio n. 28
0
 /**
  * @param int $user_id
  * @param bool $dummyObject
  * @return Customer|null
  */
 public static function createEmptyCustomer($user_id = 0, $dummyObject = true)
 {
     $model = new static();
     $model->user_id = intval($user_id);
     $model->loadDefaultValues();
     if ($model->user_id === 0 && (int) Yii::$app->getModule('shop')->registrationGuestUserInCart === 1) {
         $model->setScenario('registerUser');
     }
     $groups = PropertyGroup::getForObjectId($model->getObject()->id, true);
     $group = array_shift($groups);
     if (null !== $group) {
         $model->setPropertyGroup($group);
         $abstractModel = new AbstractModel();
         $abstractModel->setPropertiesModels(array_reduce($group->properties, function ($result, $item) {
             /** @var Property $item */
             $result[$item->key] = $item;
             return $result;
         }, []));
         $abstractModel->setAttributes(array_reduce($group->properties, function ($result, $item) use($model) {
             /** @var Property $item */
             $result[$item->key] = new PropertyValue([], $item->id, $model->getObject()->id, null);
             return $result;
         }, []));
         $abstractModel->setFormName('CustomerNew');
         $model->setAbstractModel($abstractModel);
     }
     if (!$dummyObject) {
         $model->first_name = 'Имя';
         if ($model->save()) {
             if (!empty($model->getPropertyGroup())) {
                 $model->getPropertyGroup()->appendToObjectModel($model);
             }
         } else {
             return null;
         }
     }
     return $model;
 }
Esempio n. 29
0
 /**
  *
  */
 public function invalidateModelCache()
 {
     TagDependency::invalidate(Yii::$app->cache, [ActiveRecordHelper::getObjectTag(PropertyGroup::className(), $this->property_group_id), ActiveRecordHelper::getObjectTag(Property::className(), $this->id)]);
 }
Esempio n. 30
0
 /**
  * Returns array of ids of propertyGroups for user model
  * @return array
  * @throws \Exception
  */
 private function getPropertyIdsForUsers()
 {
     return PropertyGroup::getDb()->cache(function ($db) {
         return PropertyGroup::find()->select('id')->where(['object_id' => $this->getObject()->id])->asArray()->column($db);
     }, 86400, new TagDependency(['tags' => ActiveRecordHelper::getCommonTag(PropertyGroup::className())]));
 }