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.

ImagesImportCommand   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Importance

Changes 0
Metric Value
dl 0
loc 63
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 7

3 Methods

Rating   Name   Duplication   Size   Complexity  
A actionIndex() 0 12 2
A actionImportFromCsv() 0 33 1
A updateProducts() 0 13 2
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
chdir(GlobalConfig::instance()->rootPath);
11
12
// Игнорируем  E_NOTICE и E_NOTICE прежде всего для phpThumb, чтобы не прерывить импорт
13
error_reporting(E_ALL & ~E_NOTICE & ~E_NOTICE);
14
15
class ImagesImportCommand extends AbstractImagesImportCommand
16
{
17
  public function actionIndex()
18
  {
19
    try
20
    {
21
      $this->actionImportFromCsv();
22
      //$this->updateProducts();
23
    }
24
    catch(Exception $e)
25
    {
26
      $this->logger->error($e->getMessage());
27
    }
28
  }
29
30
  public function actionImportFromCsv()
31
  {
32
    $imageWriter = new ImageWriter($this->logger);
33
    $imageWriter->previews = array(
34
      'origin' => array(4500, 4500),
35
      'big' => array(600, 460),
36
      'pre' => array(250, 190),
37
    );
38
    $imageWriter->uniqueAttribute = 'id';
39
    $imageWriter->clear = false;
40
    $imageWriter->clearTables = array('{{product_img}}');
41
    $imageWriter->defaultJpegQuality = 95;
42
    $imageWriter->phpThumbErrorExceptionToWarning = true;
43
    $imageWriter->actionWithSameFiles = ImageWriter::FILE_ACTION_RENAME_NEW_FILE;
44
    $imageWriter->actionWithExistingRecord = ImageWriter::DB_ACTION_EXISTING_RECORD_SKIP_SILENT;
45
46
    $imageAggregator = new ImageAggregator($imageWriter);
47
    $imageAggregator->groupByColumn = ImportHelper::lettersToNumber('a');
48
    $imageAggregator->imagesColumns = ImportHelper::convertColumnIndexes(ImportHelper::getLettersRange('b-ab'));
0 ignored issues
show
Documentation Bug introduced by
It seems like \ImportHelper::convertCo...etLettersRange('b-ab')) of type * is incompatible with the declared type array of property $imagesColumns.

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...
49
    /*    $imageAggregator->replace = array(
50
      'http://openfish.ru/wa-data/public/shop/products/' => ''
51
    );*/
52
53
    $imageAggregator->collectItemBufferSize = 100;
54
55
    $csvReader = new ImportCsvReader($this->logger, $imageAggregator);
56
    $csvReader->csvDelimiter = ',';
57
    $csvReader->headerRowIndex = 1;
58
    $csvReader->skipTopRowAmount = 1;
59
    $csvReader->start();
60
    $csvReader->processFiles(ImportHelper::getFiles('f/import_image'));
61
    $csvReader->finish();
62
  }
63
64
  private function updateProducts()
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
65
  {
66
    $sql = array(
67
      'UPDATE `{{product}}` SET visible=1 WHERE 1',
68
      'UPDATE `{{product}}` SET visible=0 WHERE id NOT IN (SELECT parent FROM `{{product_img}}` WHERE 1)',
69
    );
70
71
    foreach($sql as $query)
72
    {
73
      $command = new CDbCommand(Yii::app()->db, $query);
74
      $command->execute();
75
    }
76
  }
77
}