1
|
|
|
<?php
|
2
|
|
|
/**
|
3
|
|
|
* @author Alexey Tatarinov <[email protected]>
|
4
|
|
|
* @link https://github.com/shogodev/argilla/
|
5
|
|
|
* @copyright Copyright © 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(
|
|
|
|
|
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(
|
|
|
|
|
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'));
|
|
|
|
|
64
|
|
|
$productAggregator->parameterCommon = ImportHelper::convertColumnIndexes(ImportHelper::getLettersRange('z-ac'));
|
|
|
|
|
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()
|
|
|
|
|
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
|
|
|
} |
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..