GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 1ba1f4...ea41a5 )
by Alexey
05:37
created

ProductsImportCommand::getModel()   B

Complexity

Conditions 5
Paths 4

Size

Total Lines 28
Code Lines 14

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 28
rs 8.439
cc 5
eloc 14
nc 4
nop 3
1
<?php
2
/**
3
 * @author Alexey Tatarinov <[email protected]>
4
 * @link https://github.com/shogodev/argilla/
5
 * @copyright Copyright &copy; 2003-2015 Shogo
6
 * @license http://argilla.ru/LICENSE
7
 */
8
9
Yii::import('backend.modules.product.modules.import.components.*');
10
11
chdir(Yii::getPathOfAlias('frontend').'/../');
12
13
class ProductsImportCommand extends AbstractImportCommand
14
{
15
  public function actionIndex()
16
  {
17
    try
18
    {
19
      $productWriter = new ImportProductWriter($this->logger);
20
      $productWriter->clear = true;
21
      $productWriter->clearTables = array(
22
        '{{product}}',
23
        '{{product_assignment}}',
24
        '{{product_param}}',
25
        '{{product_param_variant}}',
26
        '{{product_tree_assignment}}',
27
        '{{product_section}}',
28
        '{{product_type}}',
29
        '{{product_category}}',
30
        '{{product_collection}}',
31
        '{{product_param_name}}',
32
      );
33
      $productWriter->uniqueAttribute = 'external_id';
34
      $productWriter->assignmentTree = array('type_id' => 'section_id', 'collection_id' => 'type_id');
35
      $productWriter->assignment = array('section_id', 'type_id', 'collection_id', 'category_id');
36
37
      $productAggregator = new ProductAggregator($productWriter);
38
39
      $productAggregator->assignmentDelimiter = '@';
40
      $productAggregator->parameterVariantsDelimiter = '@';
41
      $productAggregator->collectItemBufferSize = null;
42
43
      $productAggregator->groupByColumn = ImportHelper::lettersToNumber('f');
44
      $productAggregator->product = ImportHelper::convertColumnIndexes(array(
0 ignored issues
show
Documentation Bug introduced by
It seems like \ImportHelper::convertCo...> 'p', 'model' => 'f')) of type * is incompatible with the declared type array of property $product.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
45
        'name' => 'g',
46
        'articul' => 'i',
47
        'price' => 'k',
48
        'url' => 'w',
49
        'notice' => 'q',
50
        'content' => 'r',
51
        'visible' => 't',
52
        'dump' => 'l',
53
        'external_id' => 'p',
54
        'model' => 'f'
55
      ));
56
      $productAggregator->basketParameter = array(ImportHelper::lettersToNumber('h'));
57
      $productAggregator->assignment = ImportHelper::convertColumnIndexes(array(
0 ignored issues
show
Documentation Bug introduced by
It seems like \ImportHelper::convertCo... 'category_id' => 'e')) of type * is incompatible with the declared type array of property $assignment.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
58
        'section_id' => 'b',
59
        'type_id' => 'c',
60
        'collection_id' => 'd',
61
        'category_id' => 'e',
62
      ));
63
      $productAggregator->parameter = ImportHelper::convertColumnIndexes(ImportHelper::getLettersRange('z-en'));
0 ignored issues
show
Documentation Bug introduced by
It seems like \ImportHelper::convertCo...etLettersRange('z-en')) of type * is incompatible with the declared type array of property $parameter.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
64
      $productAggregator->parameterCommon = ImportHelper::convertColumnIndexes(ImportHelper::getLettersRange('z-ac'));
0 ignored issues
show
Documentation Bug introduced by
It seems like \ImportHelper::convertCo...etLettersRange('z-ac')) of type * is incompatible with the declared type array of property $parameterCommon.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
65
66
      $csvReader = new ImportCsvReader($this->logger, $productAggregator);
67
      $csvReader->csvDelimiter = ',';
68
      $csvReader->headerRowIndex = 2;
69
      $csvReader->skipTopRowAmount = 2;
70
      $csvReader->start();
71
      $csvReader->processFiles(ImportHelper::getFiles('f/prices'));
72
      $csvReader->finish();
73
74
      //$this->reindex();
75
    }
76
    catch(Exception $e)
77
    {
78
      $this->logger->error($e->getMessage());
79
    }
80
  }
81
82 View Code Duplication
  private function reindex()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
83
  {
84
    $runner = new CConsoleCommandRunner();
85
    $runner->commands = array(
86
      'indexer' => array(
87
        'class' => 'frontend.commands.IndexerCommand',
88
      ),
89
    );
90
91
    ob_start();
92
    $runner->run(array('yiic', 'indexer', 'refresh'));
93
    return ob_get_clean();
94
  }
95
}