Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use of Mage::getUrl() array parameter

Before I used to do this:

$response['url'] = Mage::getBaseUrl() .'module/controller/action?sku=' . $request['sku'] . '&qty=';

Now I am required to use ::getUrl(), but I can't seem to understand how to make use of the reserved special values (tutorial here).

So now I do this:

$response['url'] = Mage::getUrl('module/controller/action', array('sku_query' => $item['sku'], 'qty_query' => ''));

and my url string comes out like this: ...module/controller/action/sku_query/skuValue/ instead of with ? and & for the GET query strings. And also the qty is missing...

Whereas, I want it to look like ...module/controller/action?sku=skuValue&qty=


Screenshot from the debugger, to check the value of the url: screen shot from the debugger

How the code looks:

Mage::getUrl('orderbysku/producttype/showpopupinproductviewpage', array('_query' => 'sku='.$item['sku'].'&qty='))
like image 402
Syspect Avatar asked Mar 16 '26 17:03

Syspect


1 Answers

This should do the trick:

Mage::getUrl(
    'module/controller/action',
    array('_query' => 'sku=' . $item['sku'] . '&qty=')
);
like image 175
Marius Avatar answered Mar 18 '26 12:03

Marius



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!