public function create($defaultCategoryId, $basePrice, $priceCurrencyId, $taxRuleId, $baseWeight, $baseQuantity = 0)
    {
        $con = Propel::getWriteConnection(ProductTableMap::DATABASE_NAME);

        $con->beginTransaction();
        $this->dispatchEvent(TheliaEvents::BEFORE_CREATEPRODUCT, new ProductEvent($this));

        try {
            // Create the product
            $this->save($con);

            // Add the default category
            $this->setDefaultCategory($defaultCategoryId)->save($con);

            $this->setTaxRuleId($taxRuleId);

            // Create the default product sale element of this product
            $this->createProductSaleElement($con, $baseWeight, $basePrice, $basePrice, $priceCurrencyId, true, false, false, $baseQuantity);

            // Store all the stuff !
            $con->commit();

            $this->dispatchEvent(TheliaEvents::AFTER_CREATEPRODUCT, new ProductEvent($this));
        } catch (\Exception $ex) {
            $con->rollback();

            throw $ex;
        }
    }
public function create($defaultCategoryId, $basePrice, $priceCurrencyId, $taxRuleId, $baseWeight, $baseQuantity = 0)
    {
        $con = Propel::getWriteConnection(ProductTableMap::DATABASE_NAME);

        $con->beginTransaction();
        $this->dispatchEvent(TheliaEvents::BEFORE_CREATEPRODUCT, new ProductEvent($this));

        try {
            // Create the product
            $this->save($con);

            // Add the default category
            $this->setDefaultCategory($defaultCategoryId)->save($con);

            $this->setTaxRuleId($taxRuleId);

            // Create the default product sale element of this product
            $this->createProductSaleElement($con, $baseWeight, $basePrice, $basePrice, $priceCurrencyId, true, false, false, $baseQuantity);

            // Store all the stuff !
            $con->commit();

            $this->dispatchEvent(TheliaEvents::AFTER_CREATEPRODUCT, new ProductEvent($this));
        } catch (\Exception $ex) {
            $con->rollback();

            throw $ex;
        }
    }
public function create ( $ defaultCategoryId , $ basePrice , $ priceCurrencyId , $ taxRuleId , $ baseWeight , $ baseQuantity = 0 ) { $ con = Propel :: getWriteConnection ( ProductTableMap :: DATABASE_NAME ) ; $ con -> beginTransaction ( ) ; $ this -> dispatchEvent ( TheliaEvents :: BEFORE_CREATEPRODUCT , new ProductEvent ( $ this ) ) ; try { // Create the product $ this -> save ( $ con ) ; // Add the default category $ this -> setDefaultCategory ( $ defaultCategoryId ) -> save ( $ con ) ; $ this -> setTaxRuleId ( $ taxRuleId ) ; // Create the default product sale element of this product $ this -> createProductSaleElement ( $ con , $ baseWeight , $ basePrice , $ basePrice , $ priceCurrencyId , true , false , false , $ baseQuantity ) ; // Store all the stuff ! $ con -> commit ( ) ; $ this -> dispatchEvent ( TheliaEvents :: AFTER_CREATEPRODUCT , new ProductEvent ( $ this ) ) ; } catch ( \ Exception $ ex ) { $ con -> rollback ( ) ; throw $ ex ; } }
Create a new product, along with the default category ID

@param  int        $defaultCategoryId the default category ID of this product
@param  float      $basePrice         the product base price
@param  int        $priceCurrencyId   the price currency Id
@param  int        $taxRuleId         the product tax rule ID
@param  float      $baseWeight        base weight in Kg
@param  int        $baseQuantity     the product quantity (default: 0)
@throws \Exception
Create a new product along with the default category ID