public function create(ProductCreateEvent $event)
    {
        $defaultTaxRuleId = null;
        if (null !== $defaultTaxRule = TaxRuleQuery::create()->findOneByIsDefault(true)) {
            $defaultTaxRuleId = $defaultTaxRule->getId();
        }

        $product = new ProductModel();

        $product
            ->setDispatcher($this->eventDispatcher)

            ->setRef($event->getRef())
            ->setLocale($event->getLocale())
            ->setTitle($event->getTitle())
            ->setVisible($event->getVisible() ? 1 : 0)
            ->setVirtual($event->getVirtual() ? 1 : 0)
            ->setTemplateId($event->getTemplateId())

            ->create(
                $event->getDefaultCategory(),
                $event->getBasePrice(),
                $event->getCurrencyId(),
                // Set the default tax rule if not defined
                $event->getTaxRuleId() ?: $defaultTaxRuleId,
                $event->getBaseWeight(),
                $event->getBaseQuantity()
            )
        ;

        $event->setProduct($product);
    }
public function create(ProductCreateEvent $event)
    {
        $defaultTaxRuleId = null;
        if (null !== $defaultTaxRule = TaxRuleQuery::create()->findOneByIsDefault(true)) {
            $defaultTaxRuleId = $defaultTaxRule->getId();
        }

        $product = new ProductModel();

        $product
            ->setDispatcher($this->eventDispatcher)

            ->setRef($event->getRef())
            ->setLocale($event->getLocale())
            ->setTitle($event->getTitle())
            ->setVisible($event->getVisible() ? 1 : 0)
            ->setVirtual($event->getVirtual() ? 1 : 0)
            ->setTemplateId($event->getTemplateId())

            ->create(
                $event->getDefaultCategory(),
                $event->getBasePrice(),
                $event->getCurrencyId(),
                // Set the default tax rule if not defined
                $event->getTaxRuleId() ?: $defaultTaxRuleId,
                $event->getBaseWeight(),
                $event->getBaseQuantity()
            )
        ;

        $event->setProduct($product);
    }
public function create ( ProductCreateEvent $ event ) { $ defaultTaxRuleId = null ; if ( null !== $ defaultTaxRule = TaxRuleQuery :: create ( ) -> findOneByIsDefault ( true ) ) { $ defaultTaxRuleId = $ defaultTaxRule -> getId ( ) ; } $ product = new ProductModel ( ) ; $ product -> setDispatcher ( $ this -> eventDispatcher ) -> setRef ( $ event -> getRef ( ) ) -> setLocale ( $ event -> getLocale ( ) ) -> setTitle ( $ event -> getTitle ( ) ) -> setVisible ( $ event -> getVisible ( ) ? 1 : 0 ) -> setVirtual ( $ event -> getVirtual ( ) ? 1 : 0 ) -> setTemplateId ( $ event -> getTemplateId ( ) ) -> create ( $ event -> getDefaultCategory ( ) , $ event -> getBasePrice ( ) , $ event -> getCurrencyId ( ) , // Set the default tax rule if not defined $ event -> getTaxRuleId ( ) ? : $ defaultTaxRuleId , $ event -> getBaseWeight ( ) , $ event -> getBaseQuantity ( ) ) ; $ event -> setProduct ( $ product ) ; }
Create a new product entry

@param \Thelia\Core\Event\Product\ProductCreateEvent $event
Create a new product entry