public function clonePSE(ProductCloneEvent $event)
    {
        $clonedProduct = $event->getClonedProduct();

        // Get original product's PSEs
        $originalProductPSEs = ProductSaleElementsQuery::create()
            ->orderByIsDefault(Criteria::DESC)
            ->findByProductId($event->getOriginalProduct()->getId());

        /**
         * Handle PSEs
         *
         * @var int  $key
         * @var ProductSaleElements $originalProductPSE
         */
        foreach ($originalProductPSEs as $key => $originalProductPSE) {
            $currencyId = ProductPriceQuery::create()
                ->filterByProductSaleElementsId($originalProductPSE->getId())
                ->select('CURRENCY_ID')
                ->findOne();

            // The default PSE, created at the same time as the clone product, is overwritten
            $clonedProductPSEId = $this->createClonePSE($event, $originalProductPSE, $currencyId);

            $this->updateClonePSE($event, $clonedProductPSEId, $originalProductPSE, $key);

            // PSE associated images
            $originalProductPSEImages = ProductSaleElementsProductImageQuery::create()
                ->findByProductSaleElementsId($originalProductPSE->getId());

            if (null !== $originalProductPSEImages) {
                $this->clonePSEAssociatedFiles($clonedProduct->getId(), $clonedProductPSEId, $originalProductPSEImages, $type = 'image');
            }

            // PSE associated documents
            $originalProductPSEDocuments = ProductSaleElementsProductDocumentQuery::create()
                ->findByProductSaleElementsId($originalProductPSE->getId());

            if (null !== $originalProductPSEDocuments) {
                $this->clonePSEAssociatedFiles($clonedProduct->getId(), $clonedProductPSEId, $originalProductPSEDocuments, $type = 'document');
            }
        }
    }
public function clonePSE(ProductCloneEvent $event)
    {
        $clonedProduct = $event->getClonedProduct();

        // Get original product's PSEs
        $originalProductPSEs = ProductSaleElementsQuery::create()
            ->orderByIsDefault(Criteria::DESC)
            ->findByProductId($event->getOriginalProduct()->getId());

        /**
         * Handle PSEs
         *
         * @var int  $key
         * @var ProductSaleElements $originalProductPSE
         */
        foreach ($originalProductPSEs as $key => $originalProductPSE) {
            $currencyId = ProductPriceQuery::create()
                ->filterByProductSaleElementsId($originalProductPSE->getId())
                ->select('CURRENCY_ID')
                ->findOne();

            // The default PSE, created at the same time as the clone product, is overwritten
            $clonedProductPSEId = $this->createClonePSE($event, $originalProductPSE, $currencyId);

            $this->updateClonePSE($event, $clonedProductPSEId, $originalProductPSE, $key);

            // PSE associated images
            $originalProductPSEImages = ProductSaleElementsProductImageQuery::create()
                ->findByProductSaleElementsId($originalProductPSE->getId());

            if (null !== $originalProductPSEImages) {
                $this->clonePSEAssociatedFiles($clonedProduct->getId(), $clonedProductPSEId, $originalProductPSEImages, $type = 'image');
            }

            // PSE associated documents
            $originalProductPSEDocuments = ProductSaleElementsProductDocumentQuery::create()
                ->findByProductSaleElementsId($originalProductPSE->getId());

            if (null !== $originalProductPSEDocuments) {
                $this->clonePSEAssociatedFiles($clonedProduct->getId(), $clonedProductPSEId, $originalProductPSEDocuments, $type = 'document');
            }
        }
    }
public function clonePSE ( ProductCloneEvent $ event ) { $ clonedProduct = $ event -> getClonedProduct ( ) ; // Get original product's PSEs $ originalProductPSEs = ProductSaleElementsQuery :: create ( ) -> orderByIsDefault ( Criteria :: DESC ) -> findByProductId ( $ event -> getOriginalProduct ( ) -> getId ( ) ) ; /**
         * Handle PSEs
         *
         * @var int  $key
         * @var ProductSaleElements $originalProductPSE
         */ foreach ( $ originalProductPSEs as $ key => $ originalProductPSE ) { $ currencyId = ProductPriceQuery :: create ( ) -> filterByProductSaleElementsId ( $ originalProductPSE -> getId ( ) ) -> select ( 'CURRENCY_ID' ) -> findOne ( ) ; // The default PSE, created at the same time as the clone product, is overwritten $ clonedProductPSEId = $ this -> createClonePSE ( $ event , $ originalProductPSE , $ currencyId ) ; $ this -> updateClonePSE ( $ event , $ clonedProductPSEId , $ originalProductPSE , $ key ) ; // PSE associated images $ originalProductPSEImages = ProductSaleElementsProductImageQuery :: create ( ) -> findByProductSaleElementsId ( $ originalProductPSE -> getId ( ) ) ; if ( null !== $ originalProductPSEImages ) { $ this -> clonePSEAssociatedFiles ( $ clonedProduct -> getId ( ) , $ clonedProductPSEId , $ originalProductPSEImages , $ type = 'image' ) ; } // PSE associated documents $ originalProductPSEDocuments = ProductSaleElementsProductDocumentQuery :: create ( ) -> findByProductSaleElementsId ( $ originalProductPSE -> getId ( ) ) ; if ( null !== $ originalProductPSEDocuments ) { $ this -> clonePSEAssociatedFiles ( $ clonedProduct -> getId ( ) , $ clonedProductPSEId , $ originalProductPSEDocuments , $ type = 'document' ) ; } } }
Clone product's PSEs and associated datas

@param ProductCloneEvent $event
@throws \Propel\Runtime\Exception\PropelException
Clone product s PSEs and associated datas