Exemple #1
0
 private function checkChangeAsNotVariationProduct(\Ess\M2ePro\Model\Listing\Product $listingProduct)
 {
     /** @var \Ess\M2ePro\Model\Amazon\Listing\Product\Variation\Manager $variationManager */
     $variationManager = $listingProduct->getChildObject()->getVariationManager();
     $isVariationMagentoProduct = $listingProduct->getMagentoProduct()->isProductWithVariations();
     if ($isVariationMagentoProduct || !$variationManager->isVariationProduct()) {
         return false;
     }
     $variationManager->getTypeModel()->clearTypeData();
     if ($variationManager->isRelationParentType()) {
         $listingProduct->setData('general_id', NULL);
         $listingProduct->setData('is_general_id_owner', \Ess\M2ePro\Model\Amazon\Listing\Product::IS_GENERAL_ID_OWNER_NO);
         $listingProduct->setData('status', \Ess\M2ePro\Model\Listing\Product::STATUS_NOT_LISTED);
         $listingProduct->delete();
     } else {
         $variationManager->setSimpleType();
     }
     return true;
 }
Exemple #2
0
 protected function saveVariationsData(\Ess\M2ePro\Model\Listing\Product $listingProduct, $variationsData)
 {
     $additionalData = $listingProduct->getData('additional_data');
     $additionalData = is_null($additionalData) ? array() : (array) json_decode($additionalData, true);
     if (isset($variationsData['set'])) {
         $additionalData['variations_sets'] = $variationsData['set'];
     }
     if (isset($variationsData['additional']['attributes'])) {
         $additionalData['configurable_attributes'] = $variationsData['additional']['attributes'];
     }
     $listingProduct->setData('additional_data', json_encode($additionalData))->save();
 }