Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix for #21753 (2.3-develop) #22073

Merged
merged 6 commits into from
Apr 16, 2019
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ public function execute(\Magento\Framework\Event\Observer $observer)
if ($purchasedLink->getId()) {
return $this;
}
$statusToEnable = $this->_scopeConfig->getValue(
crankycyclops marked this conversation as resolved.
Show resolved Hide resolved
\Magento\Downloadable\Model\Link\Purchased\Item::XML_PATH_ORDER_ITEM_STATUS,
ScopeInterface::SCOPE_STORE,
$orderItem->getOrder()->getStoreId()
);
if (!$product) {
$product = $this->_createProductModel()->setStoreId(
$orderItem->getOrder()->getStoreId()
Expand Down Expand Up @@ -150,6 +155,8 @@ public function execute(\Magento\Framework\Event\Observer $observer)
)->setNumberOfDownloadsBought(
$numberOfDownloads
)->setStatus(
1 == $statusToEnable ?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, get value from \Magento\Sales\Model\Order\Item::STATUS_PENDING instead of hardcoded ('1') value and use the strict comparison operator ===

Copy link
Contributor Author

@crankycyclops crankycyclops Mar 31, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I implemented all of the requested changes except for the strict comparison. If you var_dump the constant and the value returned from the admin setting, you can see that the constant is an integer while the admin setting value is a string.

\Magento\Downloadable\Model\Link\Purchased\Item::LINK_STATUS_AVAILABLE :
\Magento\Downloadable\Model\Link\Purchased\Item::LINK_STATUS_PENDING
)->setCreatedAt(
$orderItem->getCreatedAt()
Expand Down