1

I am calling the below function in controller to check whether adding row to a table works or not.

public function urlAction(){
    echo "hello";
    $_orderId = "32" ;
    $enc_key = "somekeyhere";
    $model = Mage::getModel('softcopy/softcopy');
    $model->setData(
        array( 'order_id' => $_orderId,
        'key' => $enc_key,
        'downloads_count' => 0
    ))->save();
}

In the above function, I can see "hello" text for a millisecond then the page is redirecting to error reporting page.

The error states as follows:

a:5:{i:0;s:59:"The URL key contains capital letters or disallowed symbols.";i:1;s:1298:"#0 C:\xampp\htdocs\xyz\app\code\local\Efk\Softcopy\Model\Resource\Softcopy.php(210): Mage::throwException('The URL key con...')

FYI, I created the module using Ultimate module creator.

PS: The softcopy_softcopy table has the following fields:

 entity_id
 order_id
 key
 downloads_count
 date (current_time_stamp)
2

Looks like you selected the option to create url rewrites for your module. In case you don't need it, just edit the file Efk\Softcopy\Model\Resource\Softcopy.php and completely remove the method _beforeSave() from it. That should solve it.

| improve this answer | |
  • yes I stupidly kept url rewrites enabled.. and wasted my time as always.. thanks. – Mr_Green Apr 11 '14 at 11:00
  • Marius, How to load a specific row data from the table? I tried this which is not working: Mage::getModel('softcopy/softcopy')->loadByAttribute('order_id', $_orderId).. – Mr_Green Apr 11 '14 at 11:13
  • Try with $row = Mage::getModel('softcopy/softcopy')->load($_orderId, 'order_id'); – Marius Apr 11 '14 at 11:18
  • yes worked.. not sure I am being cross or magento is cross.. :/ Thanks again. – Mr_Green Apr 11 '14 at 11:19

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.