| @@ 42-128 (lines=87) @@ | ||
| 39 | * @link https://github.com/techdivision/import-product-bundle-ee |
|
| 40 | * @link http://www.techdivision.com |
|
| 41 | */ |
|
| 42 | class EeBundleOptionObserver extends BundleOptionObserver |
|
| 43 | { |
|
| 44 | ||
| 45 | /** |
|
| 46 | * The sequence product bundle option action instance. |
|
| 47 | * |
|
| 48 | * @var \TechDivision\Import\Product\Bundle\Ee\Actions\SequenceProductBundleOptionActionInterface |
|
| 49 | */ |
|
| 50 | protected $sequenceProductBundleOptionAction; |
|
| 51 | ||
| 52 | /** |
|
| 53 | * Initialize the observer with the passed product bundle processor instance. |
|
| 54 | * |
|
| 55 | * @param \TechDivision\Import\Product\Bundle\Services\ProductBundleProcessorInterface $productBundleProcessor The product bundle processor instance |
|
| 56 | * @param \TechDivision\Import\Product\Bundle\Ee\Actions\SequenceProductBundleOptionActionInterface $sequenceProductBundleOptionAction The action instance |
|
| 57 | * @param \TechDivision\Import\Observers\AttributeLoaderInterface|null $attributeLoader The attribute loader instance |
|
| 58 | * @param \TechDivision\Import\Observers\EntityMergers\EntityMergerInterface $entityMerger The entity merger instance |
|
| 59 | * @param \TechDivision\Import\Observers\StateDetectorInterface|null $stateDetector The state detector instance |
|
| 60 | */ |
|
| 61 | public function __construct( |
|
| 62 | ProductBundleProcessorInterface $productBundleProcessor, |
|
| 63 | SequenceProductBundleOptionActionInterface $sequenceProductBundleOptionAction, |
|
| 64 | AttributeLoaderInterface $attributeLoader = null, |
|
| 65 | EntityMergerInterface $entityMerger = null, |
|
| 66 | StateDetectorInterface $stateDetector = null |
|
| 67 | ) { |
|
| 68 | ||
| 69 | // initialize the parent instance |
|
| 70 | parent::__construct($productBundleProcessor, $attributeLoader, $entityMerger, $stateDetector); |
|
| 71 | ||
| 72 | // set the passed sequence product bundle option action instance |
|
| 73 | $this->sequenceProductBundleOptionAction = $sequenceProductBundleOptionAction; |
|
| 74 | } |
|
| 75 | ||
| 76 | /** |
|
| 77 | * Prepare the attributes of the entity that has to be persisted. |
|
| 78 | * |
|
| 79 | * @return array The prepared attributes |
|
| 80 | */ |
|
| 81 | protected function prepareAttributes() |
|
| 82 | { |
|
| 83 | ||
| 84 | // prepare the attributes |
|
| 85 | $attr = parent::prepareAttributes(); |
|
| 86 | ||
| 87 | // query whether or not, we found a new product bundle option |
|
| 88 | if ($attr[EntityStatus::MEMBER_NAME] === EntityStatus::STATUS_CREATE) { |
|
| 89 | $attr[MemberNames::OPTION_ID] = $this->nextIdentifier(); |
|
| 90 | } |
|
| 91 | ||
| 92 | // return the attributes |
|
| 93 | return $attr; |
|
| 94 | } |
|
| 95 | ||
| 96 | /** |
|
| 97 | * Returns the sequence product bundle option action instance. |
|
| 98 | * |
|
| 99 | * @return \TechDivision\Import\Product\Bundle\Ee\Actions\SequenceProductBundleOptionActionInterface The action instance |
|
| 100 | */ |
|
| 101 | protected function getSequenceProductBundleOptionAction() |
|
| 102 | { |
|
| 103 | return $this->sequenceProductBundleOptionAction; |
|
| 104 | } |
|
| 105 | ||
| 106 | /** |
|
| 107 | * Returns the next available product bundle option ID. |
|
| 108 | * |
|
| 109 | * @return integer The next available product bundle option ID |
|
| 110 | */ |
|
| 111 | protected function nextIdentifier() |
|
| 112 | { |
|
| 113 | return $this->getSequenceProductBundleOptionAction()->nextIdentifier(); |
|
| 114 | } |
|
| 115 | ||
| 116 | /** |
|
| 117 | * Returns the row ID for the passed SKU. |
|
| 118 | * |
|
| 119 | * @param string $sku The SKU to return the row ID for |
|
| 120 | * |
|
| 121 | * @return integer The mapped row ID |
|
| 122 | * @throws \Exception Is thrown if the SKU is not mapped yet |
|
| 123 | */ |
|
| 124 | protected function mapSku($sku) |
|
| 125 | { |
|
| 126 | return $this->getSubject()->mapSkuToRowId($sku); |
|
| 127 | } |
|
| 128 | } |
|
| 129 | ||
| @@ 42-128 (lines=87) @@ | ||
| 39 | * @link https://github.com/techdivision/import-product-bundle-ee |
|
| 40 | * @link http://www.techdivision.com |
|
| 41 | */ |
|
| 42 | class EeBundleOptionUpdateObserver extends BundleOptionUpdateObserver |
|
| 43 | { |
|
| 44 | ||
| 45 | /** |
|
| 46 | * The sequence product bundle option action instance. |
|
| 47 | * |
|
| 48 | * @var \TechDivision\Import\Product\Bundle\Ee\Actions\SequenceProductBundleOptionActionInterface |
|
| 49 | */ |
|
| 50 | protected $sequenceProductBundleOptionAction; |
|
| 51 | ||
| 52 | /** |
|
| 53 | * Initialize the observer with the passed product bundle processor instance. |
|
| 54 | * |
|
| 55 | * @param \TechDivision\Import\Product\Bundle\Services\ProductBundleProcessorInterface $productBundleProcessor The product bundle processor instance |
|
| 56 | * @param \TechDivision\Import\Product\Bundle\Ee\Actions\SequenceProductBundleOptionActionInterface $sequenceProductBundleOptionAction The action instance |
|
| 57 | * @param \TechDivision\Import\Observers\AttributeLoaderInterface|null $attributeLoader The attribute loader instance |
|
| 58 | * @param \TechDivision\Import\Observers\EntityMergers\EntityMergerInterface $entityMerger The entity merger instance |
|
| 59 | * @param \TechDivision\Import\Observers\StateDetectorInterface|null $stateDetector The state detector instance |
|
| 60 | */ |
|
| 61 | public function __construct( |
|
| 62 | ProductBundleProcessorInterface $productBundleProcessor, |
|
| 63 | SequenceProductBundleOptionActionInterface $sequenceProductBundleOptionAction, |
|
| 64 | AttributeLoaderInterface $attributeLoader = null, |
|
| 65 | EntityMergerInterface $entityMerger = null, |
|
| 66 | StateDetectorInterface $stateDetector = null |
|
| 67 | ) { |
|
| 68 | ||
| 69 | // initialize the parent instance |
|
| 70 | parent::__construct($productBundleProcessor, $attributeLoader, $entityMerger, $stateDetector); |
|
| 71 | ||
| 72 | // set the passed sequence product bundle option action instance |
|
| 73 | $this->sequenceProductBundleOptionAction = $sequenceProductBundleOptionAction; |
|
| 74 | } |
|
| 75 | ||
| 76 | /** |
|
| 77 | * Prepare the attributes of the entity that has to be persisted. |
|
| 78 | * |
|
| 79 | * @return array The prepared attributes |
|
| 80 | */ |
|
| 81 | protected function prepareAttributes() |
|
| 82 | { |
|
| 83 | ||
| 84 | // prepare the attributes |
|
| 85 | $attr = parent::prepareAttributes(); |
|
| 86 | ||
| 87 | // query whether or not, we found a new product bundle option |
|
| 88 | if ($attr[EntityStatus::MEMBER_NAME] === EntityStatus::STATUS_CREATE) { |
|
| 89 | $attr[MemberNames::OPTION_ID] = $this->nextIdentifier(); |
|
| 90 | } |
|
| 91 | ||
| 92 | // return the attributes |
|
| 93 | return $attr; |
|
| 94 | } |
|
| 95 | ||
| 96 | /** |
|
| 97 | * Returns the sequence product bundle option action instance. |
|
| 98 | * |
|
| 99 | * @return \TechDivision\Import\Product\Bundle\Ee\Actions\SequenceProductBundleOptionActionInterface The action instance |
|
| 100 | */ |
|
| 101 | protected function getSequenceProductBundleOptionAction() |
|
| 102 | { |
|
| 103 | return $this->sequenceProductBundleOptionAction; |
|
| 104 | } |
|
| 105 | ||
| 106 | /** |
|
| 107 | * Returns the next available product bundle option ID. |
|
| 108 | * |
|
| 109 | * @return integer The next available product bundle option ID |
|
| 110 | */ |
|
| 111 | protected function nextIdentifier() |
|
| 112 | { |
|
| 113 | return $this->getSequenceProductBundleOptionAction()->nextIdentifier(); |
|
| 114 | } |
|
| 115 | ||
| 116 | /** |
|
| 117 | * Return the row ID for the passed SKU. |
|
| 118 | * |
|
| 119 | * @param string $sku The SKU to return the row ID for |
|
| 120 | * |
|
| 121 | * @return integer The mapped row ID |
|
| 122 | * @throws \Exception Is thrown if the SKU is not mapped yet |
|
| 123 | */ |
|
| 124 | protected function mapSku($sku) |
|
| 125 | { |
|
| 126 | return $this->getSubject()->mapSkuToRowId($sku); |
|
| 127 | } |
|
| 128 | } |
|
| 129 | ||
| @@ 42-128 (lines=87) @@ | ||
| 39 | * @link https://github.com/techdivision/import-product-bundle-ee |
|
| 40 | * @link http://www.techdivision.com |
|
| 41 | */ |
|
| 42 | class EeBundleSelectionObserver extends BundleSelectionObserver |
|
| 43 | { |
|
| 44 | ||
| 45 | /** |
|
| 46 | * The sequence product bundle selection action instance. |
|
| 47 | * |
|
| 48 | * @var \TechDivision\Import\Product\Bundle\Ee\Actions\SequenceProductBundleSelectionActionInterface |
|
| 49 | */ |
|
| 50 | protected $sequenceProductBundleSelectionAction; |
|
| 51 | ||
| 52 | /** |
|
| 53 | * Initialize the observer with the passed product bundle processor instance. |
|
| 54 | * |
|
| 55 | * @param \TechDivision\Import\Product\Bundle\Services\ProductBundleProcessorInterface $productBundleProcessor The product bundle processor instance |
|
| 56 | * @param \TechDivision\Import\Product\Bundle\Ee\Actions\SequenceProductBundleSelectionActionInterface $sequenceProductBundleSelectionAction The action instance |
|
| 57 | * @param \TechDivision\Import\Observers\AttributeLoaderInterface|null $attributeLoader The attribute loader instance |
|
| 58 | * @param \TechDivision\Import\Observers\EntityMergers\EntityMergerInterface $entityMerger The entity merger instance |
|
| 59 | * @param \TechDivision\Import\Observers\StateDetectorInterface|null $stateDetector The state detector instance |
|
| 60 | */ |
|
| 61 | public function __construct( |
|
| 62 | ProductBundleProcessorInterface $productBundleProcessor, |
|
| 63 | SequenceProductBundleSelectionActionInterface $sequenceProductBundleSelectionAction, |
|
| 64 | AttributeLoaderInterface $attributeLoader = null, |
|
| 65 | EntityMergerInterface $entityMerger = null, |
|
| 66 | StateDetectorInterface $stateDetector = null |
|
| 67 | ) { |
|
| 68 | ||
| 69 | // initialize the parent instance |
|
| 70 | parent::__construct($productBundleProcessor, $attributeLoader, $entityMerger, $stateDetector); |
|
| 71 | ||
| 72 | // set the passed sequence product bundle selection action instance |
|
| 73 | $this->sequenceProductBundleSelectionAction = $sequenceProductBundleSelectionAction; |
|
| 74 | } |
|
| 75 | ||
| 76 | /** |
|
| 77 | * Prepare the attributes of the entity that has to be persisted. |
|
| 78 | * |
|
| 79 | * @return array The prepared attributes |
|
| 80 | */ |
|
| 81 | protected function prepareAttributes() |
|
| 82 | { |
|
| 83 | ||
| 84 | // prepare the attributes |
|
| 85 | $attr = parent::prepareAttributes(); |
|
| 86 | ||
| 87 | // query whether or not, we found a new product bundle selection |
|
| 88 | if ($attr[EntityStatus::MEMBER_NAME] === EntityStatus::STATUS_CREATE) { |
|
| 89 | $attr[MemberNames::SELECTION_ID] = $this->nextIdentifier(); |
|
| 90 | } |
|
| 91 | ||
| 92 | // return the attributes |
|
| 93 | return $attr; |
|
| 94 | } |
|
| 95 | ||
| 96 | /** |
|
| 97 | * Returns the sequence product bundle selection action instance. |
|
| 98 | * |
|
| 99 | * @return \TechDivision\Import\Product\Bundle\Ee\Actions\SequenceProductBundleSelectionActionInterface The action instance |
|
| 100 | */ |
|
| 101 | protected function getSequenceProductBundleSelectionAction() |
|
| 102 | { |
|
| 103 | return $this->sequenceProductBundleSelectionAction; |
|
| 104 | } |
|
| 105 | ||
| 106 | /** |
|
| 107 | * Returns the next available product bundle option ID. |
|
| 108 | * |
|
| 109 | * @return integer The next available product bundle option ID |
|
| 110 | */ |
|
| 111 | protected function nextIdentifier() |
|
| 112 | { |
|
| 113 | return $this->getSequenceProductBundleSelectionAction()->nextIdentifier(); |
|
| 114 | } |
|
| 115 | ||
| 116 | /** |
|
| 117 | * Returns the row ID for the passed SKU. |
|
| 118 | * |
|
| 119 | * @param string $sku The SKU to return the row ID for |
|
| 120 | * |
|
| 121 | * @return integer The mapped row ID |
|
| 122 | * @throws \Exception Is thrown if the SKU is not mapped yet |
|
| 123 | */ |
|
| 124 | protected function mapSku($sku) |
|
| 125 | { |
|
| 126 | return $this->getSubject()->mapSkuToRowId($sku); |
|
| 127 | } |
|
| 128 | } |
|
| 129 | ||
| @@ 42-128 (lines=87) @@ | ||
| 39 | * @link https://github.com/techdivision/import-product-bundle-ee |
|
| 40 | * @link http://www.techdivision.com |
|
| 41 | */ |
|
| 42 | class EeBundleSelectionUpdateObserver extends BundleSelectionUpdateObserver |
|
| 43 | { |
|
| 44 | ||
| 45 | /** |
|
| 46 | * The sequence product bundle selection action instance. |
|
| 47 | * |
|
| 48 | * @var \TechDivision\Import\Product\Bundle\Ee\Actions\SequenceProductBundleSelectionActionInterface |
|
| 49 | */ |
|
| 50 | protected $sequenceProductBundleSelectionAction; |
|
| 51 | ||
| 52 | /** |
|
| 53 | * Initialize the observer with the passed product bundle processor instance. |
|
| 54 | * |
|
| 55 | * @param \TechDivision\Import\Product\Bundle\Services\ProductBundleProcessorInterface $productBundleProcessor The product bundle processor instance |
|
| 56 | * @param \TechDivision\Import\Product\Bundle\Ee\Actions\SequenceProductBundleSelectionActionInterface $sequenceProductBundleSelectionAction The action instance |
|
| 57 | * @param \TechDivision\Import\Observers\AttributeLoaderInterface|null $attributeLoader The attribute loader instance |
|
| 58 | * @param \TechDivision\Import\Observers\EntityMergers\EntityMergerInterface $entityMerger The entity merger instance |
|
| 59 | * @param \TechDivision\Import\Observers\StateDetectorInterface|null $stateDetector The state detector instance |
|
| 60 | */ |
|
| 61 | public function __construct( |
|
| 62 | ProductBundleProcessorInterface $productBundleProcessor, |
|
| 63 | SequenceProductBundleSelectionActionInterface $sequenceProductBundleSelectionAction, |
|
| 64 | AttributeLoaderInterface $attributeLoader = null, |
|
| 65 | EntityMergerInterface $entityMerger = null, |
|
| 66 | StateDetectorInterface $stateDetector = null |
|
| 67 | ) { |
|
| 68 | ||
| 69 | // initialize the parent instance |
|
| 70 | parent::__construct($productBundleProcessor, $attributeLoader, $entityMerger, $stateDetector); |
|
| 71 | ||
| 72 | // set the passed sequence product bundle selection action instance |
|
| 73 | $this->sequenceProductBundleSelectionAction = $sequenceProductBundleSelectionAction; |
|
| 74 | } |
|
| 75 | ||
| 76 | /** |
|
| 77 | * Prepare the attributes of the entity that has to be persisted. |
|
| 78 | * |
|
| 79 | * @return array The prepared attributes |
|
| 80 | */ |
|
| 81 | protected function prepareAttributes() |
|
| 82 | { |
|
| 83 | ||
| 84 | // prepare the attributes |
|
| 85 | $attr = parent::prepareAttributes(); |
|
| 86 | ||
| 87 | // query whether or not, we found a new product bundle selection |
|
| 88 | if ($attr[EntityStatus::MEMBER_NAME] === EntityStatus::STATUS_CREATE) { |
|
| 89 | $attr[MemberNames::SELECTION_ID] = $this->nextIdentifier(); |
|
| 90 | } |
|
| 91 | ||
| 92 | // return the attributes |
|
| 93 | return $attr; |
|
| 94 | } |
|
| 95 | ||
| 96 | /** |
|
| 97 | * Returns the sequence product bundle selection action instance. |
|
| 98 | * |
|
| 99 | * @return \TechDivision\Import\Product\Bundle\Ee\Actions\SequenceProductBundleSelectionActionInterface The action instance |
|
| 100 | */ |
|
| 101 | protected function getSequenceProductBundleSelectionAction() |
|
| 102 | { |
|
| 103 | return $this->sequenceProductBundleSelectionAction; |
|
| 104 | } |
|
| 105 | ||
| 106 | /** |
|
| 107 | * Returns the next available product bundle option ID. |
|
| 108 | * |
|
| 109 | * @return integer The next available product bundle option ID |
|
| 110 | */ |
|
| 111 | protected function nextIdentifier() |
|
| 112 | { |
|
| 113 | return $this->getSequenceProductBundleSelectionAction()->nextIdentifier(); |
|
| 114 | } |
|
| 115 | ||
| 116 | /** |
|
| 117 | * Returns the row ID for the passed SKU. |
|
| 118 | * |
|
| 119 | * @param string $sku The SKU to return the row ID for |
|
| 120 | * |
|
| 121 | * @return integer The mapped row ID |
|
| 122 | * @throws \Exception Is thrown if the SKU is not mapped yet |
|
| 123 | */ |
|
| 124 | protected function mapSku($sku) |
|
| 125 | { |
|
| 126 | return $this->getSubject()->mapSkuToRowId($sku); |
|
| 127 | } |
|
| 128 | } |
|
| 129 | ||