質問
Magentoで2つの新しい税率を作成するアップグレードスクリプトに機能を作成したいと思います。
adminhtml税率コントローラーのImportPostコントローラーを見ましたが、そこには多くの作業があります。私は素敵な簡単な方法のようなものを望んでいました:
Mage::getModel('tax model')->setData('tax rate data')->save()
誰かがこれを行う方法を知っていますか?
解決
これが、オーストラリアの店のアップグレードで新しい税ルールを作成した方法です。
//get the product tax class
$productTaxClass = Mage::getModel('tax/class')
->getCollection()
->addFieldToFilter('class_name', 'Taxable Goods')
->load()
->getFirstItem();
//get the customer tax class
$customerTaxClass = Mage::getModel('tax/class')
->getCollection()
->addFieldToFilter('class_name', 'Retail Customer')
->load()
->getFirstItem();
//create a new australia tax rate/zone
$taxCalculationRate = Mage::getModel('tax/calculation_rate')
->setData(array(
"code" => "GST",
"tax_country_id" => "AU",
"tax_region_id" => "0",
"zip_is_range" => "0",
"tax_postcode" => "*",
"rate" => "10",
))->save();
//create a new tax rule
$ruleModel = Mage::getModel('tax/calculation_rule')
->setData(array(
"code" => "GST",
"tax_customer_class" => array($customerTaxClass->getId()),
"tax_product_class" => array($productTaxClass->getId()),
"tax_rate" => array($taxCalculationRate->getId()),
"priority" => "0",
"position" => "0",
))->save();
所属していません magento.stackexchange