0

What is the alternative method of following Magento 1 for Magento 2

Mage::helper("tax")->getAllRatesByProductClass()
0

Please see Alan Storms answer here: https://magento.stackexchange.com/a/10572/5769

0

I've found that method flagged as obsolete in file vendor/magento/magento2-base/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php

Looking at the comments in Magento1 original...

/**
 * Get all tax rates JSON for all product tax classes of specific store
 *
 * array(
 *      value_{$productTaxVlassId} => $rate
 * )
 *
 * @param mixed $store
 * @return string
 */

Take a look at Magento\Tax\Model\TaxCalculation class, as it seems this method does something similar (although you'll need to collect product tax classes before)

/**
 * Calculate rate based on default parameter
 *
 * @param int $productTaxClassID
 * @param int|null $customerId
 * @param string|null $storeId
 * @param bool $isDefault
 * @return float
 */
protected function getRate(
    $productTaxClassID,
    $customerId = null,
    $storeId = null,
    $isDefault = false
) {
    if ($storeId === null) {
        $storeId = $this->storeManager->getStore()->getStoreId();
    }
    if (!$isDefault) {
        $addressRequestObject = $this->calculationTool->getRateRequest(null, null, null, $storeId, $customerId);
    } else {
        $addressRequestObject = $this->calculationTool->getDefaultRateRequest($storeId, $customerId);
    }
    $addressRequestObject->setProductClassId($productTaxClassID);
    return $this->calculationTool->getRate($addressRequestObject);
}

Good luck!

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.