Ejemplo n.º 1
0
 public function cloneAssociatedContent(ProductCloneEvent $event)
 {
     // Get original product associated contents
     $originalProductAssocConts = ProductAssociatedContentQuery::create()->findByProductId($event->getOriginalProduct()->getId());
     // Set clone product associated contents
     foreach ($originalProductAssocConts as $originalProductAssocCont) {
         $clonedProductCreatePAC = new ProductAddContentEvent($event->getClonedProduct(), $originalProductAssocCont->getContentId());
         $event->getDispatcher()->dispatch(TheliaEvents::PRODUCT_ADD_CONTENT, $clonedProductCreatePAC);
     }
 }
Ejemplo n.º 2
0
 public function cloneFileI18n($originalProductFileI18ns, $clonedProductFile, $type, ProductCloneEvent $event, EventDispatcherInterface $dispatcher)
 {
     // Set clone files I18n
     /** @var ProductDocumentI18n $originalProductFileI18n */
     foreach ($originalProductFileI18ns as $originalProductFileI18n) {
         // Update file with current I18n info. Update or create I18n according to existing or absent Locale in DB
         $clonedProductFile->setLocale($originalProductFileI18n->getLocale())->setTitle($originalProductFileI18n->getTitle())->setDescription($originalProductFileI18n->getDescription())->setChapo($originalProductFileI18n->getChapo())->setPostscriptum($originalProductFileI18n->getPostscriptum());
         // Create and dispatch event
         $clonedProductUpdateFileEvent = new FileCreateOrUpdateEvent($event->getClonedProduct()->getId());
         $clonedProductUpdateFileEvent->setModel($clonedProductFile);
         switch ($type) {
             case 'images':
                 $dispatcher->dispatch(TheliaEvents::IMAGE_UPDATE, $clonedProductUpdateFileEvent);
                 break;
             case 'documents':
                 $dispatcher->dispatch(TheliaEvents::DOCUMENT_UPDATE, $clonedProductUpdateFileEvent);
                 break;
         }
     }
 }
Ejemplo n.º 3
0
 public function updateClonePSE(ProductCloneEvent $event, $clonedProductPSEId, ProductSaleElements $originalProductPSE, $key)
 {
     $originalProductPSEPrice = ProductPriceQuery::create()->findOneByProductSaleElementsId($originalProductPSE->getId());
     $clonedProductUpdatePSEEvent = new ProductSaleElementUpdateEvent($event->getClonedProduct(), $clonedProductPSEId);
     $clonedProductUpdatePSEEvent->setReference($event->getClonedProduct()->getRef() . '-' . ($key + 1))->setIsdefault($originalProductPSE->getIsDefault())->setFromDefaultCurrency(0)->setWeight($originalProductPSE->getWeight())->setQuantity($originalProductPSE->getQuantity())->setOnsale($originalProductPSE->getPromo())->setIsnew($originalProductPSE->getNewness())->setEanCode($originalProductPSE->getEanCode())->setTaxRuleId($event->getOriginalProduct()->getTaxRuleId())->setPrice($originalProductPSEPrice->getPrice())->setSalePrice($originalProductPSEPrice->getPromoPrice())->setCurrencyId($originalProductPSEPrice->getCurrencyId());
     $this->eventDispatcher->dispatch(TheliaEvents::PRODUCT_UPDATE_PRODUCT_SALE_ELEMENT, $clonedProductUpdatePSEEvent);
 }
Ejemplo n.º 4
0
 public function cloneAccessories(ProductCloneEvent $event)
 {
     // Get original product accessories
     $originalProductAccessoryList = AccessoryQuery::create()->findByProductId($event->getOriginalProduct()->getId());
     // Set clone product accessories
     foreach ($originalProductAccessoryList as $originalProductAccessory) {
         $clonedProductAddAccessoryEvent = new ProductAddAccessoryEvent($event->getClonedProduct(), $originalProductAccessory->getAccessory());
         $event->getDispatcher()->dispatch(TheliaEvents::PRODUCT_ADD_ACCESSORY, $clonedProductAddAccessoryEvent);
     }
 }