|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* TechDivision\Import\Product\Bundle\Subjects\BundleSubject |
|
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 2019 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-bundle |
|
18
|
|
|
* @link http://www.techdivision.com |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
namespace TechDivision\Import\Product\Bundle\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 bundles. |
|
30
|
|
|
* |
|
31
|
|
|
* @author Tim Wagner <[email protected]> |
|
32
|
|
|
* @copyright 2019 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-bundle |
|
35
|
|
|
* @link http://www.techdivision.com |
|
36
|
|
|
*/ |
|
37
|
|
|
class BundleSubject extends AbstractProductSubject implements CleanUpColumnsSubjectInterface |
|
38
|
|
|
{ |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* The trait that provides the functionality to handle bundle import on subject level. |
|
42
|
|
|
* |
|
43
|
|
|
* @var \TechDivision\Import\Product\Bundle\Subjects\BundleSubjectTrait |
|
44
|
|
|
*/ |
|
45
|
|
|
use BundleSubjectTrait; |
|
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 the 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
|
|
|
|