diff --git a/app/code/Magento/Catalog/Model/Product/Type/Price.php b/app/code/Magento/Catalog/Model/Product/Type/Price.php index 0e16080c1fe0c..121bfd836f8bc 100644 --- a/app/code/Magento/Catalog/Model/Product/Type/Price.php +++ b/app/code/Magento/Catalog/Model/Product/Type/Price.php @@ -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(); diff --git a/app/code/Magento/Catalog/Pricing/Price/GroupPrice.php b/app/code/Magento/Catalog/Pricing/Price/GroupPrice.php index 0b7eb45d35935..2fd4b52aa5bc9 100644 --- a/app/code/Magento/Catalog/Pricing/Price/GroupPrice.php +++ b/app/code/Magento/Catalog/Pricing/Price/GroupPrice.php @@ -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(); diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Pricing/Price/GroupPriceTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Pricing/Price/GroupPriceTest.php index af64271e3b099..00ae9c4c71d5f 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Pricing/Price/GroupPriceTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Pricing/Price/GroupPriceTest.php @@ -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)); @@ -204,7 +207,7 @@ public function testGroupPriceCustomerGroupInProduct() ->will($this->returnValue( [ [ - 'cust_group' => 3, + 'cust_group' => $customerGroup, 'website_price' => $groupPrice, ], ] @@ -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() {