Example #1
0
 \Thelia\Model\TaxQuery::create()->find()->delete();
 \Thelia\Model\Base\TaxRuleQuery::create()->find()->delete();
 \Thelia\Model\Base\TaxRuleCountryQuery::create()->find()->delete();
 $stmt = $con->prepare("SET foreign_key_checks = 1");
 $stmt->execute();
 /* 10% tax */
 $tax10p = new \Thelia\Model\Tax();
 $tax10p->setType('PricePercentTaxType')->setRequirements(array('percent' => 10))->save();
 /* 8% tax */
 $tax8p = new \Thelia\Model\Tax();
 $tax8p->setType('PricePercentTaxType')->setRequirements(array('percent' => 8))->save();
 /* fix 5 tax */
 $tax5 = new \Thelia\Model\Tax();
 $tax5->setType('FixAmountTaxType')->setRequirements(array('amount' => 5))->save();
 /* 1% tax */
 $tax1p = new \Thelia\Model\Tax();
 $tax1p->setType('PricePercentTaxType')->setRequirements(array('percent' => 1))->save();
 /* tax rule */
 $taxRule = new \Thelia\Model\TaxRule();
 $taxRule->save();
 /* add 4 taxes to the rule for France (64) */
 $taxRuleCountry = new \Thelia\Model\TaxRuleCountry();
 $taxRuleCountry->setTaxRule($taxRule)->setCountryId(64)->setTax($tax10p)->setPosition(1)->save();
 $taxRuleCountry = new \Thelia\Model\TaxRuleCountry();
 $taxRuleCountry->setTaxRule($taxRule)->setCountryId(64)->setTax($tax8p)->setPosition(1)->save();
 $taxRuleCountry = new \Thelia\Model\TaxRuleCountry();
 $taxRuleCountry->setTaxRule($taxRule)->setCountryId(64)->setTax($tax5)->setPosition(2)->save();
 $taxRuleCountry = new \Thelia\Model\TaxRuleCountry();
 $taxRuleCountry->setTaxRule($taxRule)->setCountryId(64)->setTax($tax1p)->setPosition(3)->save();
 foreach (\Thelia\Model\ProductQuery::create()->find() as $productActiveRecord) {
     $productActiveRecord->setTaxRule($taxRule)->save();
Example #2
0
 if (null === $us) {
     $us = new \Thelia\Model\FeatureI18n();
     $us->setLocale('en_US')->setFeature($feature);
 }
 $us->setTitle('Ecotax');
 $us->save($con);
 echo "Adding ecotax\n";
 $tax = null;
 if (null !== $forceEcotaxId) {
     $tax = \Thelia\Model\TaxQuery::create()->findPk($forceEcotaxId);
     if (null === $tax) {
         echo "Tax `{$forceEcotaxId}` not found\n";
     }
 }
 if (null === $tax) {
     $tax = new \Thelia\Model\Tax();
     $tax->setType('FeatureFixAmountTaxType')->setSerializedRequirements(base64_encode(sprintf('{"feature":%s}', $feature->getId())));
     $tax->save();
     echo sprintf("Ecotax added with ID \n", $tax->getId());
 }
 $fr = \Thelia\Model\Base\TaxI18nQuery::create()->filterByLocale('fr_FR')->filterByTax($tax)->findOne();
 if (null === $fr) {
     $fr = new \Thelia\Model\TaxI18n();
     $fr->setLocale('fr_FR')->setTax($tax);
 }
 $fr->setTitle('Ecotaxe');
 $fr->save($con);
 $us = \Thelia\Model\Base\TaxI18nQuery::create()->filterByLocale('en_US')->filterByTax($tax)->findOne();
 if (null === $us) {
     $us = new \Thelia\Model\TaxI18n();
     $us->setLocale('en_US')->setTax($tax);