1

I have try with this code make tax rule programmatically. but it's not working infact model not loaded. you can see this code :

$objectManagers = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$fixtureTaxRule = $objectManagers->create('Magento\Tax\Model\Calculation\Rule');

i have get this error :

Class 'Magento\TestFramework\Helper\Bootstrap' not found

can you please suggest how can i create tax rule ?

4

Finally i have solve this issue. Now you can use this code and i hope it's also beneficial for you guys.

 $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
 $fixtureTaxRule = $objectManager->create(\Magento\Tax\Model\Calculation\Rule::class);
 $fixtureTaxRule->setCode("Test");
 $fixtureTaxRule->setPriority(0);
 $fixtureTaxRule->setCustomerTaxClassIds(array(3));
 $fixtureTaxRule->setProductTaxClassIds(array(2));
 $fixtureTaxRule->setTaxRateIds(array(3));
 $fixtureTaxRule->save();
  • Hi, Can you please share your whole code in your answer? – Kaushal Suthar Feb 10 '17 at 11:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.