1

I have created a plugin for a particular function. That function is also calling another protected function of the core file.

public function afterPopulateTaxRateData(
    \Magento\Tax\Model\Calculation\Rate\Converter $subject,
    $result,
    $formData
) {
    if ($this->_helper->isEnable()) {
        if (isset($formData['zip_is_range']) && $formData['zip_is_range']) {
            if ($this->_helper->isRangeEnable()) {
                $result->setTaxCity($this->extractFormData($formData, 'tax_city'));
            } else {
                $result->setTaxCity("");
            }
        } else {
            $result->setTaxCity($this->extractFormData($formData, 'tax_city'));
        }
    }

    return $result;
}

How to call the protected function extractFormData inside this plugin.

Thanks.

7
  • 2
    Try to call $subject->extractFormData(). Hope this will work Nov 7, 2019 at 5:01
  • Copy extractFormData function from the core and put it in your plugin or else use $subject->extractFormData() and check it. Nov 7, 2019 at 5:01
  • I used $subject->extractFormData() .But it throws .....Uncaught Error: Call to protected method Magento\\Tax\\Model\\Calculation\\Rate\\Converter::extractFormData() from context 'XXX\\YYY\\Plugin\\Converter' in /var/www/html/magento231/app/code/XXX/YYY/Plugin/Converter.php:50
    – Mahi M
    Nov 7, 2019 at 7:09
  • Copy extractFormData function from the core and put it in your plugin and check it. Nov 7, 2019 at 8:29
  • Yes. I used that. But, Magento returns duplicate code is there.
    – Mahi M
    Nov 7, 2019 at 11:19

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.