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

#10803 update OrderService to return correct bool value for cancel me… #10919

Merged
merged 2 commits into from Sep 23, 2017

Conversation

freakphp
Copy link
Contributor

@freakphp freakphp commented Sep 17, 2017

…thod

Update OrderService to return correct bool value for cancel method

Description

Magento/Sales/Model/Service/OrderService::cancel method was returning always true even if cancel method in Magento/Sales/Model/Order didn't do anything cause of canCancel validation.
OrderService cancel method will invoke canCancel to check if order can be canceled and return correct value.

Fixed Issues (if relevant)

  1. When canceling order with OrderService, the cancel method always saves the order and returns true, even if the order can not be canceled. #10803: When canceling order with OrderService, the cancel method always saves the order and returns true, even if the order can not be canceled

Manual testing scenarios

  1. Requesting API rest endpoint /V1/orders/:id/cancel for the order which can not be canceled should return false

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@magento-cicd2
Copy link
Contributor

magento-cicd2 commented Sep 17, 2017

CLA assistant check
All committers have signed the CLA.

@ishakhsuvarov ishakhsuvarov added this to the September 2017 milestone Sep 17, 2017
@@ -87,7 +87,8 @@ public function __construct(
public function cancel($id)
{
$order = $this->orderRepository->get($id);
if ((bool)$order->cancel()) {
if ((bool)$order->canCancel()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove (bool) casting, it is useless within if anyway.

Copy link
Contributor

Choose a reason for hiding this comment

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

fixed

@orlangur orlangur self-assigned this Sep 18, 2017
 - update OrderService to return correct bool value for cancel method
 - removed redundant type casting
@ishakhsuvarov ishakhsuvarov self-assigned this Sep 18, 2017
@magento-team magento-team merged commit d4cddf7 into magento:develop Sep 23, 2017
magento-team pushed a commit that referenced this pull request Sep 23, 2017
@strell strell mentioned this pull request Sep 30, 2017
4 tasks
strell added a commit to strell/magento2 that referenced this pull request Sep 30, 2017
From db79dbf Mon Sep 17 00:00:00 2001
From: freakphp <mail@freak.io>
Date: Sun, 17 Sep 2017 12:52:00 +0200
Subject: [PATCH 1/2] magento#10803 update OrderService to return correct bool value for cancel method

From d4cddf7 Mon Sep 17 00:00:00 2001
From: Ievgen Shakhsuvarov <ishakhsuvarov@users.noreply.github.com>
Date: Mon, 18 Sep 2017 12:22:00 +0200
Subject: [PATCH 2/2] magento#10919: update OrderService to return correct bool value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants