I want to convert this code from Magento 1 to Magento 2 , it is normally converted like this but I think there is an error
Code In Magento 2 but still Mage::log exist
foreach ($results['data'] as $data) { if ($data->countryCode != $params['countryCode']) { Mage::log($data->countryCode . ' - ' . $params['countryCode'], Zend_Log::DEBUG, 'cap.log'); Mage::log($results, Zend_Log::DEBUG, 'cap.log'); unset($results['data']); }
The code checked
foreach ($results['data'] as $data) { if ($data->countryCode != $params['countryCode']) { $this->logger->debug($data->countryCode . ' - ' . $params['countryCode']); $this->logger->debug($results); unset($results['data']); }
Additional code for better comprehension of the problem
use Psr\Log\LoggerInterface;
class xxxx extends yyyyy
{
/**
* @var $logger
* */
protected $logger;
/**
* @var Data
*/
protected $helper;
/**
* xxxx constructor.
* @param Data $helper
* @param LoggerInterface $logger
*/
public function __construct(
Data $helper,
LoggerInterface $logger
) {
$this->helper = $helper;
$this->logger=$logger;
parent::__construct();
}
Thanks in advance,