Magento2 如何在Magento 2中的购物车页面上获取税率?

Magento2 如何在Magento 2中的购物车页面上获取税率?,magento2,shipping,tax,Magento2,Shipping,Tax,我不熟悉Magento 2。 我正在自定义购物车页面上的表费率功能。 最终运费计算包括计算燃油税成本、重量和目的地 目前,我能够在代码中使用静态燃油税成本计算最终值。但是,该值应该可以从后端进行配置 因此,我添加了Fuelevy作为后端的一个税类,并希望在购物车页面上获取它以计算运费 表名为“mgic税计算率”。 如何获取这些记录,或者是否有其他方法可以获取这些记录?首先,为此表创建模型: \供应商\Module\Model\MgicTaxCaculationRate.php <?php

我不熟悉Magento 2。 我正在自定义购物车页面上的表费率功能。 最终运费计算包括计算燃油税成本、重量和目的地

目前,我能够在代码中使用静态燃油税成本计算最终值。但是,该值应该可以从后端进行配置

因此,我添加了Fuelevy作为后端的一个税类,并希望在购物车页面上获取它以计算运费

表名为“mgic税计算率”。
如何获取这些记录,或者是否有其他方法可以获取这些记录?

首先,为此表创建模型:

\供应商\Module\Model\MgicTaxCaculationRate.php

<?php
/**
 * Copyright © 2015. All rights reserved.
 */

namespace Vendor\Module\Model;

class MgicTaxCaculationRate extends \Magento\Framework\Model\AbstractModel
{
    /**
     * Constructor
     *
     * @return void
     */
    protected function _construct()
    {
        parent::_construct();
        $this->_init('Vendor\Module\Model\Resource\MgicTaxCaculationRate');
    }
}
<?php
/**
 * Copyright © 2015. All rights reserved.
 */

namespace Vendor\Module\Model\Resource;

class MgicTaxCaculationRate extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
{
    /**
     * Model Initialization
     *
     * @return void
     */
    protected function _construct()
    {
        $this->_init('mgic_tax_calculation_rate', 'mgic_tax_calculation_rate_id');
    }
}

首先,为该表创建模型:

\供应商\Module\Model\MgicTaxCaculationRate.php

<?php
/**
 * Copyright © 2015. All rights reserved.
 */

namespace Vendor\Module\Model;

class MgicTaxCaculationRate extends \Magento\Framework\Model\AbstractModel
{
    /**
     * Constructor
     *
     * @return void
     */
    protected function _construct()
    {
        parent::_construct();
        $this->_init('Vendor\Module\Model\Resource\MgicTaxCaculationRate');
    }
}
<?php
/**
 * Copyright © 2015. All rights reserved.
 */

namespace Vendor\Module\Model\Resource;

class MgicTaxCaculationRate extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
{
    /**
     * Model Initialization
     *
     * @return void
     */
    protected function _construct()
    {
        $this->_init('mgic_tax_calculation_rate', 'mgic_tax_calculation_rate_id');
    }
}