Code to enable downloadable product?Programtically add files to downloadable productresumable link in downloadable productChange staus of downloadable product in magento after purchase?Magento - Downloadable product link emptyDownloadable product with shippingMagento How to add configurable product while placing order programatically?Help for Downloadable ProductOverride event for downloadable productMagento 2.1 downloadable product linkError when creating downloadable product
Can a Necromancer reuse the corpses left behind from slain undead?
Did arcade monitors have same pixel aspect ratio as TV sets?
How must one send away the mother bird?
Does the Mind Blank spell prevent the target from being frightened?
Why do IPv6 unique local addresses have to have a /48 prefix?
My friend sent me a screenshot of a transaction hash, but when I search for it I find divergent data. What happened?
Why we can't differentiate a polynomial equation as many times as we wish?
Is camera lens focus an exact point or a range?
What is the difference between "Do you interest" and "...interested in" something?
Difference between -| and |- in TikZ
Should I install hardwood flooring or cabinets first?
Transformation of random variables and joint distributions
Can a significant change in incentives void an employment contract?
Varistor? Purpose and principle
List of people who lose a child in תנ"ך
What's the difference between 違法 and 不法?
Can I use my Chinese passport to enter China after I acquired another citizenship?
How will losing mobility of one hand affect my career as a programmer?
When quoting, must I also copy hyphens used to divide words that continue on the next line?
Did US corporations pay demonstrators in the German demonstrations against article 13?
On a tidally locked planet, would time be quantized?
Gibbs free energy in standard state vs. equilibrium
Indicating multiple different modes of speech (fantasy language or telepathy)
How can Trident be so inexpensive? Will it orbit Triton or just do a (slow) flyby?
Code to enable downloadable product?
Programtically add files to downloadable productresumable link in downloadable productChange staus of downloadable product in magento after purchase?Magento - Downloadable product link emptyDownloadable product with shippingMagento How to add configurable product while placing order programatically?Help for Downloadable ProductOverride event for downloadable productMagento 2.1 downloadable product linkError when creating downloadable product
I have the following custom payment plugin controller. After purchase, it does not enable a downloadable product. I am wondering if there is a simple line of code I could add so that this controller will also make the downloadable product in the order Available.
//Get data from Gateway postback
$data = $this->getRequest()->getPost();
$orderId = $data['orderid'];
if ($data['reasonForDeclineCode'] == '')
// Payment was successful, so update the order's state, send order email and move to the success page
$order = Mage::getModel('sales/order');
$order->loadByIncrementId($orderId);
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, 'Gateway has authorized the payment.');
$order->setStatus('processing');
$order->sendNewOrderEmail();
$order->setEmailSent(true);
$order->save();
Mage::getSingleton('checkout/session')->unsQuoteId();
Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/success', array('_secure'=>true));
else
// Payment was declined, so update the order's state, send order email and move to the success page
$order = Mage::getModel('sales/order');
$order->loadByIncrementId($orderId);
$order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true, 'Gateway has declined the payment.');
//$order->sendNewOrderEmail();
//$order->setEmailSent(true);
$order->save();
Mage::getSingleton('checkout/session')->unsQuoteId();
Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/failed', array('_secure'=>true));
I ended up "solving" the problem by adding the following code to invoice successful orders after $order->setStatus('processing'); and before $order->sendNewOrderEmail(); however now I have a problem where every time an order is placed, the status on previous successful orders once again gets updated with processing and complete. This happens many more times. So far it's just an annoyance and bad for my database but not hurting anything. I will look into it later but if someone has a hint.
//create invoice for the order
$invoice = $order->prepareInvoice()
->setTransactionId($order->getId())
->addComment("Invoice created by payment processor plugin.")
->register()
->pay();
$transaction_save = Mage::getModel('core/resource_transaction')
->addObject($invoice)
->addObject($invoice->getOrder());
$transaction_save->save();
//now create shipment
//after creation of shipment, the order auto gets status COMPLETE
$shipment = $order->prepareShipment();
if( $shipment )
$shipment->register();
$order->setIsInProcess(true);
$transaction_save = Mage::getModel('core/resource_transaction')
->addObject($shipment)
->addObject($shipment->getOrder())
->save();
product magento-1 downloadable
bumped to the homepage by Community♦ 12 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I have the following custom payment plugin controller. After purchase, it does not enable a downloadable product. I am wondering if there is a simple line of code I could add so that this controller will also make the downloadable product in the order Available.
//Get data from Gateway postback
$data = $this->getRequest()->getPost();
$orderId = $data['orderid'];
if ($data['reasonForDeclineCode'] == '')
// Payment was successful, so update the order's state, send order email and move to the success page
$order = Mage::getModel('sales/order');
$order->loadByIncrementId($orderId);
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, 'Gateway has authorized the payment.');
$order->setStatus('processing');
$order->sendNewOrderEmail();
$order->setEmailSent(true);
$order->save();
Mage::getSingleton('checkout/session')->unsQuoteId();
Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/success', array('_secure'=>true));
else
// Payment was declined, so update the order's state, send order email and move to the success page
$order = Mage::getModel('sales/order');
$order->loadByIncrementId($orderId);
$order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true, 'Gateway has declined the payment.');
//$order->sendNewOrderEmail();
//$order->setEmailSent(true);
$order->save();
Mage::getSingleton('checkout/session')->unsQuoteId();
Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/failed', array('_secure'=>true));
I ended up "solving" the problem by adding the following code to invoice successful orders after $order->setStatus('processing'); and before $order->sendNewOrderEmail(); however now I have a problem where every time an order is placed, the status on previous successful orders once again gets updated with processing and complete. This happens many more times. So far it's just an annoyance and bad for my database but not hurting anything. I will look into it later but if someone has a hint.
//create invoice for the order
$invoice = $order->prepareInvoice()
->setTransactionId($order->getId())
->addComment("Invoice created by payment processor plugin.")
->register()
->pay();
$transaction_save = Mage::getModel('core/resource_transaction')
->addObject($invoice)
->addObject($invoice->getOrder());
$transaction_save->save();
//now create shipment
//after creation of shipment, the order auto gets status COMPLETE
$shipment = $order->prepareShipment();
if( $shipment )
$shipment->register();
$order->setIsInProcess(true);
$transaction_save = Mage::getModel('core/resource_transaction')
->addObject($shipment)
->addObject($shipment->getOrder())
->save();
product magento-1 downloadable
bumped to the homepage by Community♦ 12 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I have the following custom payment plugin controller. After purchase, it does not enable a downloadable product. I am wondering if there is a simple line of code I could add so that this controller will also make the downloadable product in the order Available.
//Get data from Gateway postback
$data = $this->getRequest()->getPost();
$orderId = $data['orderid'];
if ($data['reasonForDeclineCode'] == '')
// Payment was successful, so update the order's state, send order email and move to the success page
$order = Mage::getModel('sales/order');
$order->loadByIncrementId($orderId);
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, 'Gateway has authorized the payment.');
$order->setStatus('processing');
$order->sendNewOrderEmail();
$order->setEmailSent(true);
$order->save();
Mage::getSingleton('checkout/session')->unsQuoteId();
Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/success', array('_secure'=>true));
else
// Payment was declined, so update the order's state, send order email and move to the success page
$order = Mage::getModel('sales/order');
$order->loadByIncrementId($orderId);
$order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true, 'Gateway has declined the payment.');
//$order->sendNewOrderEmail();
//$order->setEmailSent(true);
$order->save();
Mage::getSingleton('checkout/session')->unsQuoteId();
Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/failed', array('_secure'=>true));
I ended up "solving" the problem by adding the following code to invoice successful orders after $order->setStatus('processing'); and before $order->sendNewOrderEmail(); however now I have a problem where every time an order is placed, the status on previous successful orders once again gets updated with processing and complete. This happens many more times. So far it's just an annoyance and bad for my database but not hurting anything. I will look into it later but if someone has a hint.
//create invoice for the order
$invoice = $order->prepareInvoice()
->setTransactionId($order->getId())
->addComment("Invoice created by payment processor plugin.")
->register()
->pay();
$transaction_save = Mage::getModel('core/resource_transaction')
->addObject($invoice)
->addObject($invoice->getOrder());
$transaction_save->save();
//now create shipment
//after creation of shipment, the order auto gets status COMPLETE
$shipment = $order->prepareShipment();
if( $shipment )
$shipment->register();
$order->setIsInProcess(true);
$transaction_save = Mage::getModel('core/resource_transaction')
->addObject($shipment)
->addObject($shipment->getOrder())
->save();
product magento-1 downloadable
I have the following custom payment plugin controller. After purchase, it does not enable a downloadable product. I am wondering if there is a simple line of code I could add so that this controller will also make the downloadable product in the order Available.
//Get data from Gateway postback
$data = $this->getRequest()->getPost();
$orderId = $data['orderid'];
if ($data['reasonForDeclineCode'] == '')
// Payment was successful, so update the order's state, send order email and move to the success page
$order = Mage::getModel('sales/order');
$order->loadByIncrementId($orderId);
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, 'Gateway has authorized the payment.');
$order->setStatus('processing');
$order->sendNewOrderEmail();
$order->setEmailSent(true);
$order->save();
Mage::getSingleton('checkout/session')->unsQuoteId();
Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/success', array('_secure'=>true));
else
// Payment was declined, so update the order's state, send order email and move to the success page
$order = Mage::getModel('sales/order');
$order->loadByIncrementId($orderId);
$order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true, 'Gateway has declined the payment.');
//$order->sendNewOrderEmail();
//$order->setEmailSent(true);
$order->save();
Mage::getSingleton('checkout/session')->unsQuoteId();
Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/failed', array('_secure'=>true));
I ended up "solving" the problem by adding the following code to invoice successful orders after $order->setStatus('processing'); and before $order->sendNewOrderEmail(); however now I have a problem where every time an order is placed, the status on previous successful orders once again gets updated with processing and complete. This happens many more times. So far it's just an annoyance and bad for my database but not hurting anything. I will look into it later but if someone has a hint.
//create invoice for the order
$invoice = $order->prepareInvoice()
->setTransactionId($order->getId())
->addComment("Invoice created by payment processor plugin.")
->register()
->pay();
$transaction_save = Mage::getModel('core/resource_transaction')
->addObject($invoice)
->addObject($invoice->getOrder());
$transaction_save->save();
//now create shipment
//after creation of shipment, the order auto gets status COMPLETE
$shipment = $order->prepareShipment();
if( $shipment )
$shipment->register();
$order->setIsInProcess(true);
$transaction_save = Mage::getModel('core/resource_transaction')
->addObject($shipment)
->addObject($shipment->getOrder())
->save();
product magento-1 downloadable
product magento-1 downloadable
edited Apr 17 '16 at 7:28
7ochem
5,80493768
5,80493768
asked Mar 4 '15 at 19:30
TayKimchiTayKimchi
11
11
bumped to the homepage by Community♦ 12 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 12 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I've never used downloadable products, but looking at the code, it seems that the downloadable module hooks into the event sales_order_save_commit_after in order to change the status of the download. Since your code calls save on an order object the event itself should be triggered, which means Mage_Downloadable_Model_Observer::setLinkStatus should be called.
Looking at the code in there, it seems that you can change whether an item is set as available by changing the setting System > Configuration > Catalog > Downloadable Product Options > Order Item Status to Enable Downloads. By default it seems to be Invoiced. Looking at your code it doesn't seem to invoice the order so I'm guessing this is why they don't become available. Changing it to Pending may yield the behaviour you expect.
Disclaimer: I'm not 100% sure of the repercussions of doing this, but looking at the code I can't imagine there would be anything untoward.
So you could also go with generating a invoice, than it would be just fine.
– Jeroen
Mar 4 '15 at 20:27
Thank you for taking a look @Cags. The problem with changing Downloadable Availability from Invoiced to Pending is that if the customer manually visits/checkout/onepage/successafter being redirected to my payment processors page, the downloads will become available without them needing to pay. @jeroen-boersma When I manually generate an invoice, the downloads do become available. I noticed this a while back and tried to use PlumRocket's Auto Invoice plugin but then the orders would become invoiced without activating downloads. I will look some more but this is driving me nuts... ty again
– TayKimchi
Mar 5 '15 at 23:00
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f59662%2fcode-to-enable-downloadable-product%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I've never used downloadable products, but looking at the code, it seems that the downloadable module hooks into the event sales_order_save_commit_after in order to change the status of the download. Since your code calls save on an order object the event itself should be triggered, which means Mage_Downloadable_Model_Observer::setLinkStatus should be called.
Looking at the code in there, it seems that you can change whether an item is set as available by changing the setting System > Configuration > Catalog > Downloadable Product Options > Order Item Status to Enable Downloads. By default it seems to be Invoiced. Looking at your code it doesn't seem to invoice the order so I'm guessing this is why they don't become available. Changing it to Pending may yield the behaviour you expect.
Disclaimer: I'm not 100% sure of the repercussions of doing this, but looking at the code I can't imagine there would be anything untoward.
So you could also go with generating a invoice, than it would be just fine.
– Jeroen
Mar 4 '15 at 20:27
Thank you for taking a look @Cags. The problem with changing Downloadable Availability from Invoiced to Pending is that if the customer manually visits/checkout/onepage/successafter being redirected to my payment processors page, the downloads will become available without them needing to pay. @jeroen-boersma When I manually generate an invoice, the downloads do become available. I noticed this a while back and tried to use PlumRocket's Auto Invoice plugin but then the orders would become invoiced without activating downloads. I will look some more but this is driving me nuts... ty again
– TayKimchi
Mar 5 '15 at 23:00
add a comment |
I've never used downloadable products, but looking at the code, it seems that the downloadable module hooks into the event sales_order_save_commit_after in order to change the status of the download. Since your code calls save on an order object the event itself should be triggered, which means Mage_Downloadable_Model_Observer::setLinkStatus should be called.
Looking at the code in there, it seems that you can change whether an item is set as available by changing the setting System > Configuration > Catalog > Downloadable Product Options > Order Item Status to Enable Downloads. By default it seems to be Invoiced. Looking at your code it doesn't seem to invoice the order so I'm guessing this is why they don't become available. Changing it to Pending may yield the behaviour you expect.
Disclaimer: I'm not 100% sure of the repercussions of doing this, but looking at the code I can't imagine there would be anything untoward.
So you could also go with generating a invoice, than it would be just fine.
– Jeroen
Mar 4 '15 at 20:27
Thank you for taking a look @Cags. The problem with changing Downloadable Availability from Invoiced to Pending is that if the customer manually visits/checkout/onepage/successafter being redirected to my payment processors page, the downloads will become available without them needing to pay. @jeroen-boersma When I manually generate an invoice, the downloads do become available. I noticed this a while back and tried to use PlumRocket's Auto Invoice plugin but then the orders would become invoiced without activating downloads. I will look some more but this is driving me nuts... ty again
– TayKimchi
Mar 5 '15 at 23:00
add a comment |
I've never used downloadable products, but looking at the code, it seems that the downloadable module hooks into the event sales_order_save_commit_after in order to change the status of the download. Since your code calls save on an order object the event itself should be triggered, which means Mage_Downloadable_Model_Observer::setLinkStatus should be called.
Looking at the code in there, it seems that you can change whether an item is set as available by changing the setting System > Configuration > Catalog > Downloadable Product Options > Order Item Status to Enable Downloads. By default it seems to be Invoiced. Looking at your code it doesn't seem to invoice the order so I'm guessing this is why they don't become available. Changing it to Pending may yield the behaviour you expect.
Disclaimer: I'm not 100% sure of the repercussions of doing this, but looking at the code I can't imagine there would be anything untoward.
I've never used downloadable products, but looking at the code, it seems that the downloadable module hooks into the event sales_order_save_commit_after in order to change the status of the download. Since your code calls save on an order object the event itself should be triggered, which means Mage_Downloadable_Model_Observer::setLinkStatus should be called.
Looking at the code in there, it seems that you can change whether an item is set as available by changing the setting System > Configuration > Catalog > Downloadable Product Options > Order Item Status to Enable Downloads. By default it seems to be Invoiced. Looking at your code it doesn't seem to invoice the order so I'm guessing this is why they don't become available. Changing it to Pending may yield the behaviour you expect.
Disclaimer: I'm not 100% sure of the repercussions of doing this, but looking at the code I can't imagine there would be anything untoward.
answered Mar 4 '15 at 20:15
Peter O'CallaghanPeter O'Callaghan
4,37731631
4,37731631
So you could also go with generating a invoice, than it would be just fine.
– Jeroen
Mar 4 '15 at 20:27
Thank you for taking a look @Cags. The problem with changing Downloadable Availability from Invoiced to Pending is that if the customer manually visits/checkout/onepage/successafter being redirected to my payment processors page, the downloads will become available without them needing to pay. @jeroen-boersma When I manually generate an invoice, the downloads do become available. I noticed this a while back and tried to use PlumRocket's Auto Invoice plugin but then the orders would become invoiced without activating downloads. I will look some more but this is driving me nuts... ty again
– TayKimchi
Mar 5 '15 at 23:00
add a comment |
So you could also go with generating a invoice, than it would be just fine.
– Jeroen
Mar 4 '15 at 20:27
Thank you for taking a look @Cags. The problem with changing Downloadable Availability from Invoiced to Pending is that if the customer manually visits/checkout/onepage/successafter being redirected to my payment processors page, the downloads will become available without them needing to pay. @jeroen-boersma When I manually generate an invoice, the downloads do become available. I noticed this a while back and tried to use PlumRocket's Auto Invoice plugin but then the orders would become invoiced without activating downloads. I will look some more but this is driving me nuts... ty again
– TayKimchi
Mar 5 '15 at 23:00
So you could also go with generating a invoice, than it would be just fine.
– Jeroen
Mar 4 '15 at 20:27
So you could also go with generating a invoice, than it would be just fine.
– Jeroen
Mar 4 '15 at 20:27
Thank you for taking a look @Cags. The problem with changing Downloadable Availability from Invoiced to Pending is that if the customer manually visits
/checkout/onepage/success after being redirected to my payment processors page, the downloads will become available without them needing to pay. @jeroen-boersma When I manually generate an invoice, the downloads do become available. I noticed this a while back and tried to use PlumRocket's Auto Invoice plugin but then the orders would become invoiced without activating downloads. I will look some more but this is driving me nuts... ty again– TayKimchi
Mar 5 '15 at 23:00
Thank you for taking a look @Cags. The problem with changing Downloadable Availability from Invoiced to Pending is that if the customer manually visits
/checkout/onepage/success after being redirected to my payment processors page, the downloads will become available without them needing to pay. @jeroen-boersma When I manually generate an invoice, the downloads do become available. I noticed this a while back and tried to use PlumRocket's Auto Invoice plugin but then the orders would become invoiced without activating downloads. I will look some more but this is driving me nuts... ty again– TayKimchi
Mar 5 '15 at 23:00
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f59662%2fcode-to-enable-downloadable-product%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown