1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* TechDivision\Import\Product\Bundle\Observers\BundleSelectionUpdateObserver |
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-bundle |
18
|
|
|
* @link http://www.techdivision.com |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace TechDivision\Import\Product\Bundle\Observers; |
22
|
|
|
|
23
|
|
|
use TechDivision\Import\Product\Bundle\Utils\ColumnKeys; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Oberserver that provides functionality for the bundle selection add/update operation. |
27
|
|
|
* |
28
|
|
|
* @author Tim Wagner <[email protected]> |
29
|
|
|
* @copyright 2016 TechDivision GmbH <[email protected]> |
30
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
31
|
|
|
* @link https://github.com/techdivision/import-product-bundle |
32
|
|
|
* @link http://www.techdivision.com |
33
|
|
|
*/ |
34
|
|
|
class BundleSelectionUpdateObserver extends BundleSelectionObserver |
35
|
|
|
{ |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Initialize the bundle selection with the passed attributes and returns an instance. |
39
|
|
|
* |
40
|
|
|
* @param array $attr The bundle selection attributes |
41
|
|
|
* |
42
|
|
|
* @return array The initialized bundle selection |
43
|
|
|
*/ |
44
|
|
|
protected function initializeBundleSelection(array $attr) |
45
|
|
|
{ |
46
|
|
|
|
47
|
|
|
// load the product bundle option SKU/ID |
48
|
|
|
$parentProductId = $this->mapSkuToEntityId($this->getValue(ColumnKeys::BUNDLE_PARENT_SKU)); |
|
|
|
|
49
|
|
|
|
50
|
|
|
// load the product ID |
51
|
|
|
$productId = $this->mapSkuToEntityId($this->getValue(ColumnKeys::BUNDLE_VALUE_SKU)); |
|
|
|
|
52
|
|
|
|
53
|
|
|
// load the actual option ID |
54
|
|
|
$optionId = $this->getLastOptionId(); |
55
|
|
|
|
56
|
|
|
// try to load the bundle selection with the passed option/product/parent product ID |
57
|
|
|
if ($entity = $this->loadBundleSelection($optionId, $productId, $parentProductId)) { |
58
|
|
|
return $this->mergeEntity($entity, $attr); |
|
|
|
|
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
// simply return the attributes |
62
|
|
|
return $attr; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Load's the bundle selection value with the passed option/product/parent product ID. |
67
|
|
|
* |
68
|
|
|
* @param integer $optionId The option ID of the bundle selection to be returned |
69
|
|
|
* @param integer $productId The product ID of the bundle selection to be returned |
70
|
|
|
* @param integer $parentProductId The parent product ID of the bundle selection to be returned |
71
|
|
|
* |
72
|
|
|
* @return array The bundle selection |
73
|
|
|
*/ |
74
|
|
|
protected function loadBundleSelection($optionId, $productId, $parentProductId) |
75
|
|
|
{ |
76
|
|
|
return $this->getSubject()->loadBundleSelection($optionId, $productId, $parentProductId); |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.