As we know that magento restrict some core PHP functions which we found in MEQP2 which contains the rules.
Let’s start to over come this issue.
As we know Magento 2 is using Zend Framework ther is a class \Zend\Uri\Uri
First initialise Zend Uri in your class constructor.
public function __construct( \Zend\Uri\Uri $zendUri ) { $this->zendUri = $zendUri; }
Now set the query string and then get it as array.
$data = $this->getRequest()->getParams(); $this->zendUri->setQuery($data); $formatedParams = $this->zendUri->getQueryAsArray(); // $formatedParams is an array of query string.
$formatedParams contains an array of your querystring.
print_r($formatedParams) // Output Array ( [product] => Array ( [1] => Array ( [name] => Customization [price] => 100 ) ) )
Be the first to comment.