File tree 1 file changed +9
-4
lines changed
app/code/Magento/Downloadable/Observer
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)
131
131
ScopeInterface::SCOPE_STORE
132
132
);
133
133
$ 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
+
134
142
foreach ($ linkIds as $ linkId ) {
135
143
if (isset ($ links [$ linkId ])) {
136
144
$ linkPurchasedItem = $ this ->_createPurchasedItemModel ()->setPurchasedId (
@@ -158,9 +166,7 @@ public function execute(\Magento\Framework\Event\Observer $observer)
158
166
)->setNumberOfDownloadsBought (
159
167
$ numberOfDownloads
160
168
)->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
164
170
)->setCreatedAt (
165
171
$ orderItem ->getCreatedAt ()
166
172
)->setUpdatedAt (
@@ -170,7 +176,6 @@ public function execute(\Magento\Framework\Event\Observer $observer)
170
176
}
171
177
}
172
178
}
173
-
174
179
return $ this ;
175
180
}
176
181
You can’t perform that action at this time.
0 commit comments