0

I have created the 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.

  • 1
    Try to call $subject->extractFormData(). Hope this will work – Ranganathan Nov 7 '19 at 5:01
  • Copy extractFormData function from the core and put it in your plugin or else use $subject->extractFormData() and check it. – Dhaduk Mitesh Nov 7 '19 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 '19 at 7:09
  • Copy extractFormData function from the core and put it in your plugin and check it. – Dhaduk Mitesh Nov 7 '19 at 8:29
  • Yes. I used that. But, Magento returns duplicate code is there. – Mahi M Nov 7 '19 at 11:19

Your Answer

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

Browse other questions tagged or ask your own question.