1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* TechDivision\Import\Product\Variant\Subjects\VariantSubject |
5
|
|
|
* |
6
|
|
|
* NOTICE OF LICENSE |
7
|
|
|
* |
8
|
|
|
* This source file is subject to the Open Software License (OSL 3.0) |
9
|
|
|
* that is available through the world-wide-web at this URL: |
10
|
|
|
* http://opensource.org/licenses/osl-3.0.php |
11
|
|
|
* |
12
|
|
|
* PHP version 5 |
13
|
|
|
* |
14
|
|
|
* @author Tim Wagner <[email protected]> |
15
|
|
|
* @copyright 2016 TechDivision GmbH <[email protected]> |
16
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
17
|
|
|
* @link https://github.com/techdivision/import-product-variant |
18
|
|
|
* @link http://www.techdivision.com |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace TechDivision\Import\Product\Variant\Subjects; |
22
|
|
|
|
23
|
|
|
use TechDivision\Import\Utils\RegistryKeys; |
24
|
|
|
use TechDivision\Import\Product\Utils\ConfigurationKeys; |
25
|
|
|
use TechDivision\Import\Product\Subjects\AbstractProductSubject; |
26
|
|
|
use TechDivision\Import\Subjects\CleanUpColumnsSubjectInterface; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* A subject implementation that handles the process to import product variants. |
30
|
|
|
* |
31
|
|
|
* @author Tim Wagner <[email protected]> |
32
|
|
|
* @copyright 2016 TechDivision GmbH <[email protected]> |
33
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
34
|
|
|
* @link https://github.com/techdivision/import-product-variant |
35
|
|
|
* @link http://www.techdivision.com |
36
|
|
|
*/ |
37
|
|
|
class VariantSubject extends AbstractProductSubject implements CleanUpColumnsSubjectInterface |
38
|
|
|
{ |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* The trait that provides the functionality to import variants on subject level. |
42
|
|
|
* |
43
|
|
|
* @var \TechDivision\Import\Product\Variant\Subjects\VariantSubjectTrait |
44
|
|
|
*/ |
45
|
|
|
use VariantSubjectTrait; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Intializes the previously loaded global data for exactly one variants. |
49
|
|
|
* |
50
|
|
|
* @param string $serial The serial of the actual import |
51
|
|
|
* |
52
|
|
|
* @return void |
53
|
|
|
*/ |
54
|
|
|
public function setUp($serial) |
55
|
|
|
{ |
56
|
|
|
|
57
|
|
|
// invoke parent method |
58
|
|
|
parent::setUp($serial); |
59
|
|
|
|
60
|
|
|
// load the entity manager and the registry processor |
61
|
|
|
$registryProcessor = $this->getRegistryProcessor(); |
62
|
|
|
|
63
|
|
|
// load the status of the actual import process |
64
|
|
|
$status = $registryProcessor->getAttribute(RegistryKeys::STATUS); |
65
|
|
|
|
66
|
|
|
// load the SKU => entity ID mapping |
67
|
|
|
$this->skuEntityIdMapping = $status[RegistryKeys::SKU_ENTITY_ID_MAPPING]; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Merge the columns from the configuration with all image type columns to define which |
72
|
|
|
* columns should be cleaned-up. |
73
|
|
|
* |
74
|
|
|
* @return array The columns that has to be cleaned-up |
75
|
|
|
*/ |
76
|
|
|
public function getCleanUpColumns() |
77
|
|
|
{ |
78
|
|
|
|
79
|
|
|
// initialize the array for the columns that has to be cleaned-up |
80
|
|
|
$cleanUpColumns = array(); |
81
|
|
|
|
82
|
|
|
// query whether or not an array has been specified in the configuration |
83
|
|
|
if ($this->getConfiguration()->hasParam(ConfigurationKeys::CLEAN_UP_EMPTY_COLUMNS)) { |
84
|
|
|
$cleanUpColumns = $this->getConfiguration()->getParam(ConfigurationKeys::CLEAN_UP_EMPTY_COLUMNS); |
|
|
|
|
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
// return the array with the column names |
88
|
|
|
return $cleanUpColumns; |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|