-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Fix bug 27490: Can't change customer group when placing an admin order #27501
Conversation
Hi @tna274. Thank you for your contribution
For more details, please, review the Magento Contributor Guide documentation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @tna274
Thanks for your contribution.
Please change your code according to Magento technical guideline
Also please consider refactoring this class.
Instead of introducing new code complexity try to separate implementation for adminhtml and frontend introducing 2 observers and declare them at respective levels via events.xml
To avoid code duplication please use decomposition.
app/code/Magento/Quote/Observer/Frontend/Quote/Address/CollectTotalsObserver.php
Outdated
Show resolved
Hide resolved
app/code/Magento/Quote/Observer/Frontend/Quote/Address/CollectTotalsObserver.php
Outdated
Show resolved
Hide resolved
Hi @Stepa4man |
Hi, @tna274 can you please look through failed tests and merge conflicts? |
@magento run all tests |
Working with MFTF test. |
@magento run Magento Health Index |
@magento run Static Tests |
Added MFTF test. |
@magento run Functional Tests B2B |
@magento run all tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @tna274
Thanks for your contribution.
Please take a look at my comments.
*/ | ||
protected function assignCustomerGroupConditions($groupId) | ||
{ | ||
return $groupId !== null ? true : false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need it here? Why don't you just write return $groupId !== null
?
if ($groupId !== null | ||
&& !( | ||
$this->state->getAreaCode() == Area::AREA_ADMINHTML | ||
&& $groupId == $this->groupManagement->getNotLoggedInGroup()->getId() | ||
)) { | ||
return true; | ||
} | ||
|
||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please put those long difficult conditions to separate private methods with proper naming and shorten this function to just return statement:
return $groupId !== null && !($this->isAdminArea() && $this->isNotLoggedInGroup($groupId));
At least like this.
You can think even more to make this code more readable.
/** | ||
* @var \Magento\Quote\Observer\Backend\Quote\Address\CollectTotalsObserver | ||
*/ | ||
protected $model; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please replace all protected properties with private.
protected $model; | ||
|
||
/** | ||
* @var MockObject |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add the proper type annotation to all class properties
*/ | ||
protected function setUp() | ||
{ | ||
$this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't use ObjectManager helper, use new
statement instead.
$this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); | ||
$this->storeId = 1; | ||
$this->customerMock = $this->getMockForAbstractClass( | ||
\Magento\Customer\Api\Data\CustomerInterface::class, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please import all class names.
$this->state->getAreaCode() == Area::AREA_ADMINHTML | ||
&& $groupId == $this->groupManagement->getNotLoggedInGroup()->getId() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use strict comparison operator
@@ -0,0 +1,488 @@ | |||
<?php |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please declare strict types for every php file
@tna274 I am closing this PR now due to inactivity. |
Hi @tna274, thank you for your contribution! |
Description (*)
Fix bug 27490: Can't change customer group when placing an admin orderRelated Pull Requests
Fixed Issues (if relevant)
Manual testing scenarios (*)
Questions or comments
Contribution checklist (*)