File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
app/code/Magento/Downloadable/Observer Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -131,6 +131,14 @@ public function execute(\Magento\Framework\Event\Observer $observer)
131131 ScopeInterface::SCOPE_STORE
132132 );
133133 $ linkPurchased ->setLinkSectionTitle ($ linkSectionTitle )->save ();
134+
135+ $ linkStatus = \Magento \Downloadable \Model \Link \Purchased \Item::LINK_STATUS_PENDING ;
136+ if ($ orderStatusToEnableItem == \Magento \Sales \Model \Order \Item::STATUS_PENDING
137+ || $ orderItem ->getOrder ()->getState () == \Magento \Sales \Model \Order::STATE_COMPLETE
138+ ) {
139+ $ linkStatus = \Magento \Downloadable \Model \Link \Purchased \Item::LINK_STATUS_AVAILABLE ;
140+ }
141+
134142 foreach ($ linkIds as $ linkId ) {
135143 if (isset ($ links [$ linkId ])) {
136144 $ linkPurchasedItem = $ this ->_createPurchasedItemModel ()->setPurchasedId (
@@ -158,9 +166,7 @@ public function execute(\Magento\Framework\Event\Observer $observer)
158166 )->setNumberOfDownloadsBought (
159167 $ numberOfDownloads
160168 )->setStatus (
161- \Magento \Sales \Model \Order \Item::STATUS_PENDING == $ orderStatusToEnableItem ?
162- \Magento \Downloadable \Model \Link \Purchased \Item::LINK_STATUS_AVAILABLE :
163- \Magento \Downloadable \Model \Link \Purchased \Item::LINK_STATUS_PENDING
169+ $ linkStatus
164170 )->setCreatedAt (
165171 $ orderItem ->getCreatedAt ()
166172 )->setUpdatedAt (
@@ -170,7 +176,6 @@ public function execute(\Magento\Framework\Event\Observer $observer)
170176 }
171177 }
172178 }
173-
174179 return $ this ;
175180 }
176181
You can’t perform that action at this time.
0 commit comments