Commit 18fd989c8470036a97cbb0ffcfc76307f3582841
Merge remote-tracking branch 'origin/master'
Showing
3 changed files
with
14 additions
and
17 deletions
Show diff stats
console/ImportController.php
| ... | ... | @@ -19,7 +19,9 @@ class ImportController extends Controller { |
| 19 | 19 | |
| 20 | 20 | |
| 21 | 21 | |
| 22 | - public function actionProducts($lang) { | |
| 22 | + public function actionProducts() { | |
| 23 | + | |
| 24 | + $lang = 'ru'; | |
| 23 | 25 | |
| 24 | 26 | Language::setCurrent($lang); |
| 25 | 27 | |
| ... | ... | @@ -27,11 +29,13 @@ class ImportController extends Controller { |
| 27 | 29 | $this->errors[] = 'Task already executed'; |
| 28 | 30 | return Controller::EXIT_CODE_ERROR; |
| 29 | 31 | } |
| 32 | + | |
| 30 | 33 | $ff = fopen(Yii::getAlias('@uploadDir/goProducts.lock'), 'w+'); |
| 31 | 34 | fclose($ff); |
| 32 | 35 | $model = new Import(); |
| 33 | 36 | $model->goProducts(0, null); |
| 34 | 37 | unlink(Yii::getAlias('@uploadDir/goProducts_'.$lang.'.lock')); |
| 38 | + | |
| 35 | 39 | return Controller::EXIT_CODE_NORMAL; |
| 36 | 40 | } |
| 37 | 41 | ... | ... |
models/Import.php
| ... | ... | @@ -622,23 +622,15 @@ |
| 622 | 622 | $connection = Yii::$app->getDb(); |
| 623 | 623 | |
| 624 | 624 | |
| 625 | - $connection->createCommand()->addPrimaryKey('product_variant_option_pkey','product_variant_option',['product_variant_id', 'option_id'])->execute(); | |
| 626 | - $connection->createCommand()->addPrimaryKey('product_option_pkey','product_option',['product_id', 'option_id'])->execute(); | |
| 627 | - $connection->createCommand()->addForeignKey('product_variant_option_product_variant_product_variant_id_fk','product_variant_option','product_variant_id','product_variant','id')->execute(); | |
| 628 | - $connection->createCommand()->addForeignKey('product_variant_option_tax_option_tax_option_id_fk','product_variant_option','option_id','tax_option','id')->execute(); | |
| 629 | - $connection->createCommand()->addForeignKey('product_option_product_product_id_fk','product_option','product_id','product','id','CASCADE','CASCADE' )->execute(); | |
| 630 | - $connection->createCommand()->addForeignKey('product_option_tax_option_tax_option_id_fk','product_option','option_id', 'tax_option', 'id','CASCADE','CASCADE' )->execute(); | |
| 631 | 625 | |
| 626 | + $connection->createCommand()->dropForeignKey('product_option_tax_option_tax_option_id_fk','product_option')->execute(); | |
| 627 | + $connection->createCommand()->dropForeignKey('product_option_product_product_id_fk','product_option')->execute(); | |
| 628 | + $connection->createCommand()->dropForeignKey('product_variant_option_tax_option_tax_option_id_fk','product_variant_option')->execute(); | |
| 629 | + $connection->createCommand()->dropForeignKey('product_variant_option_product_variant_product_variant_id_fk','product_variant_option')->execute(); | |
| 630 | + $connection->createCommand()->dropPrimaryKey('product_option_pkey','product_option')->execute(); | |
| 631 | + $connection->createCommand()->dropForeignKey('product_variant_option_pkey','product_variant_option')->execute(); | |
| 632 | 632 | |
| 633 | -// $connection->createCommand()->dropForeignKey('product_option_tax_option_tax_option_id_fk','product_option')->execute(); | |
| 634 | -// $connection->createCommand()->dropForeignKey('product_option_product_product_id_fk','product_option')->execute(); | |
| 635 | -// $connection->createCommand()->dropForeignKey('product_variant_option_tax_option_tax_option_id_fk','product_variant_option')->execute(); | |
| 636 | -// $connection->createCommand()->dropForeignKey('product_variant_option_product_variant_product_variant_id_fk','product_variant_option')->execute(); | |
| 637 | -// $connection->createCommand()->dropPrimaryKey('product_option_pkey','product_option')->execute(); | |
| 638 | -// $connection->createCommand()->dropForeignKey('product_variant_option_pkey','product_variant_option')->execute(); | |
| 639 | 633 | |
| 640 | - | |
| 641 | - sleep(1); | |
| 642 | 634 | while (( empty( $limit ) || $j++ < $limit ) && ( $data = fgetcsv($handle, 10000, ";") ) !== false) { |
| 643 | 635 | try { |
| 644 | 636 | |
| ... | ... | @@ -677,7 +669,7 @@ |
| 677 | 669 | |
| 678 | 670 | // 5 Описание товара |
| 679 | 671 | $product_body = $data[ 3 ]; |
| 680 | - | |
| 672 | + | |
| 681 | 673 | // 6 Фильтр |
| 682 | 674 | $filters = explode('*', $data[ 4 ]); |
| 683 | 675 | |
| ... | ... | @@ -798,7 +790,7 @@ |
| 798 | 790 | $connection->createCommand()->addForeignKey('product_option_tax_option_tax_option_id_fk','product_option','option_id', 'tax_option', 'id','CASCADE','CASCADE' )->execute(); |
| 799 | 791 | |
| 800 | 792 | |
| 801 | - | |
| 793 | + | |
| 802 | 794 | $result = [ |
| 803 | 795 | 'end' => feof($handle), |
| 804 | 796 | 'from' => ftell($handle), | ... | ... |