public function generateCombinations(ProductCombinationGenerationEvent $event)
    {
        $con = Propel::getWriteConnection(ProductSaleElementsTableMap::DATABASE_NAME);

        $con->beginTransaction();

        try {
            // Delete all product's productSaleElement
            ProductSaleElementsQuery::create()->filterByProductId($event->product->getId())->delete();

            $isDefault = true;

            // Create all combinations
            foreach ($event->getCombinations() as $combinationAttributesAvIds) {
                // Create the PSE
                $saleElement = $event->getProduct()->createProductSaleElement(
                    $con,
                    $event->getWeight(),
                    $event->getPrice(),
                    $event->getSalePrice(),
                    $event->getCurrencyId(),
                    $isDefault,
                    $event->getOnsale(),
                    $event->getIsnew(),
                    $event->getQuantity(),
                    $event->getEanCode(),
                    $event->getReference()
                );

                $isDefault = false;

                $this->createCombination($con, $saleElement, $combinationAttributesAvIds);
            }

            // Store all the stuff !
            $con->commit();
        } catch (\Exception $ex) {
            $con->rollback();

            throw $ex;
        }
    }
public function generateCombinations(ProductCombinationGenerationEvent $event)
    {
        $con = Propel::getWriteConnection(ProductSaleElementsTableMap::DATABASE_NAME);

        $con->beginTransaction();

        try {
            // Delete all product's productSaleElement
            ProductSaleElementsQuery::create()->filterByProductId($event->product->getId())->delete();

            $isDefault = true;

            // Create all combinations
            foreach ($event->getCombinations() as $combinationAttributesAvIds) {
                // Create the PSE
                $saleElement = $event->getProduct()->createProductSaleElement(
                    $con,
                    $event->getWeight(),
                    $event->getPrice(),
                    $event->getSalePrice(),
                    $event->getCurrencyId(),
                    $isDefault,
                    $event->getOnsale(),
                    $event->getIsnew(),
                    $event->getQuantity(),
                    $event->getEanCode(),
                    $event->getReference()
                );

                $isDefault = false;

                $this->createCombination($con, $saleElement, $combinationAttributesAvIds);
            }

            // Store all the stuff !
            $con->commit();
        } catch (\Exception $ex) {
            $con->rollback();

            throw $ex;
        }
    }
public function generateCombinations ( ProductCombinationGenerationEvent $ event ) { $ con = Propel :: getWriteConnection ( ProductSaleElementsTableMap :: DATABASE_NAME ) ; $ con -> beginTransaction ( ) ; try { // Delete all product's productSaleElement ProductSaleElementsQuery :: create ( ) -> filterByProductId ( $ event -> product -> getId ( ) ) -> delete ( ) ; $ isDefault = true ; // Create all combinations foreach ( $ event -> getCombinations ( ) as $ combinationAttributesAvIds ) { // Create the PSE $ saleElement = $ event -> getProduct ( ) -> createProductSaleElement ( $ con , $ event -> getWeight ( ) , $ event -> getPrice ( ) , $ event -> getSalePrice ( ) , $ event -> getCurrencyId ( ) , $ isDefault , $ event -> getOnsale ( ) , $ event -> getIsnew ( ) , $ event -> getQuantity ( ) , $ event -> getEanCode ( ) , $ event -> getReference ( ) ) ; $ isDefault = false ; $ this -> createCombination ( $ con , $ saleElement , $ combinationAttributesAvIds ) ; } // Store all the stuff ! $ con -> commit ( ) ; } catch ( \ Exception $ ex ) { $ con -> rollback ( ) ; throw $ ex ; } }
Generate combinations. All existing combinations for the product are deleted.

@param  ProductCombinationGenerationEvent $event
@throws \Exception
Generate combinations . All existing combinations for the product are deleted .