1

I'm creating a module that sends data to a custom API when creating an order and/or customer and when one of them changes. It also holds a magento shell script to send initial data. The contents of the shell script is just a simple wrapper of the module.

As I'm testing the module, it seems that shipment view urls generated from the admin page do work, but the very same code generates a different, not working, url when ran from the shell script. The code that generates the order view url works in both cases.

Here is the code that generates the shipment view url and is used in the event listeners as in the shell script

/**
 * @param $shipment
 * @return mixed
 */
private function getShipmentUrl($shipment)
{
    $shipmentId = Mage::getModel('sales/order_shipment')
        ->loadByIncrementId($shipment->getIncrementId())
        ->getId();
    $this->logger->log($shipmentId);
    return Mage::helper('adminhtml')
        ->getUrl(
            'adminhtml/sales_shipment/view',
            array('shipment_id' => $shipmentId, '_type'=> Mage_Core_Model_Store::URL_TYPE_WEB));
}

There are urls generated from this code, the only difference is the key part. This url is generated when the event gets fired: /admin/sales_shipment/view/shipment_id/33/key/ee1409fa12d53056b2cf4fdf691e1a7c/ and this url is generated from the shell script: /admin/sales_shipment/view/shipment_id/33/key/5610bd5ecf1d0e67b3e752b0ae026e7f/

As I understand the key has to be in the sessions. If this is true, than the view order url code should also generate a not working url when the shell script gets executed, but this is not the case.

1 Answer 1

1

You are somehow right. The url key is not in the session but depends on a values stored in the session that changes with every session regeneration.
The url generated by the event works because you are on the same session when you generate it and when you test it.
The url generated by the shell does not work because it's a completely different session.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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