Where to begin? An AJAX call is made to the Index controller action like so:


The controller Index action contains:

public function storeNotificationProductDataAction()
    header('Access-Control-Allow-Origin: *');
    $notifySuccessMes =  Mage::getStoreConfig('Outofstocknotification/general/activate_apptha_outofstock_notify_success_mes');
    $statusOfInsert = Mage::getModel('outofstocknotification/outofstocknotification')->notifyDataInserted();
    $statusOfInsert = intval($statusOfInsert);

    if ($statusOfInsert) {
        echo $notifySuccessMes;
    } else {
        echo "okay";

The getModel() above calls the following model:

public function notifyDataInserted() {
    $isArray = count($_GET);
    $resource = Mage::getSingleton('core/resource');
    $read = $resource->getConnection('write');


    $tPrefix = (string) Mage::getConfig()->getTablePrefix();
    $stockNotifiTable = $tPrefix . 'outofstocknotification';

    if ($isArray) {
        ...blah blah blah db stuff

The var_dump() retuns an empty array: array(0) { }. The AJAX calls fails with canceled but a direct call to the URL results in okay.

So, the GET variable is empty in the model. Please tell me why?

Also, this is NOT my code, please don't hate :)

  • Instead of $_GET try to use Mage::app()->getRequest()->getParams(). – Marius Jun 14 '13 at 12:44
  • Thx Marius, I switched to that but no dice. Good practice tho :) – Jongosi Jun 14 '13 at 13:17
  • 1
    What is the value of ctrlPath in the Ajax request code? – Vinai Jun 14 '13 at 13:45

Resolved, And so, so simple in the end. The URL definition (ctrlPath) was defined as insecure:

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . 'outofstocknotification/index/storeNotificationProductData';

Instead I switched to secure, like this:


And it works wonderfully! Thanks to Vinai for the pointer! :) Now to tidy up this horrible code!

  • 3
    Try using Mage::app()->getStore()->getUrl('outofstocknotification/index/storeNotificationProductData', array('_secure' => true)) instead (a bit cleaner) – Vinai Jun 14 '13 at 14:12

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.