Skip to content

Commit

Permalink
MAGETWO-32666: [GITHUB] Allow to use "0" as customer group id #593
Browse files Browse the repository at this point in the history
  • Loading branch information
slavvka committed Jan 16, 2015
1 parent 5dde4a3 commit 184473f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/code/Magento/Catalog/Model/Product/Type/Price.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ public function getTierPrice($qty, $product)
*/
protected function _getCustomerGroupId($product)
{
if ($product->getCustomerGroupId()) {
if (!is_null($product->getCustomerGroupId())) {
return $product->getCustomerGroupId();
}
return $this->_customerSession->getCustomerGroupId();
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Catalog/Pricing/Price/GroupPrice.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function getValue()
*/
protected function getCustomerGroupId()
{
if ($this->product->getCustomerGroupId()) {
if (!is_null($this->product->getCustomerGroupId())) {
return (int) $this->product->getCustomerGroupId();
}
return (int) $this->customerSession->getCustomerGroupId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,17 @@ public function testGroupPriceCustomerGroupInSession()

/**
* test get group price, customer group in session
*
* @param int $customerGroup
* @dataProvider dataProviderGroupPriceCustomerGroupInProduct
*/
public function testGroupPriceCustomerGroupInProduct()
public function testGroupPriceCustomerGroupInProduct($customerGroup)
{
$groupPrice = 80;
$convertedPrice = 56.23;
$this->productMock->expects($this->exactly(2))
->method('getCustomerGroupId')
->will($this->returnValue(3));
->will($this->returnValue($customerGroup));
$this->productMock->expects($this->once())
->method('getResource')
->will($this->returnValue($this->productResourceMock));
Expand All @@ -204,7 +207,7 @@ public function testGroupPriceCustomerGroupInProduct()
->will($this->returnValue(
[
[
'cust_group' => 3,
'cust_group' => $customerGroup,
'website_price' => $groupPrice,
],
]
Expand All @@ -217,8 +220,16 @@ public function testGroupPriceCustomerGroupInProduct()
$this->assertEquals($convertedPrice, $this->groupPrice->getValue());
}

public function dataProviderGroupPriceCustomerGroupInProduct()
{
return [
[0],
[3],
];
}

/**
* test get group price, attribut is noy srt
* test get group price, attribute is not set
*/
public function testGroupPriceAttributeIsNotSet()
{
Expand Down

0 comments on commit 184473f

Please sign in to comment.