cancel
Showing results for 
Search instead for 
Did you mean: 

CE 2.3 TierPriceStorageInterface returns error: No such entity with Customer Group

CE 2.3 TierPriceStorageInterface returns error: No such entity with Customer Group

Anyone know why error "No such entity with Customer Group" would be thrown.  I'm using customer group 32000 which is ALL GROUPS afaik. It should be valid.

 

Below is the validation code:

private function retrieveGroupValue($code)
     {
         if (!isset($this->customerGroupsByCode[$code])) {
             $searchCriteria = $this->searchCriteriaBuilder->addFilters(
                 [
                     $this->filterBuilder->setField('customer_group_code')->setValue($code)->create()
                 ]
             );
             $items = $this->customerGroupRepository->getList($searchCriteria->create())->getItems();
             $item = array_shift($items);
 
             if (!$item) {
                 return false;
             }
 
             $this->customerGroupsByCode[strtolower($item->getCode())] = $item->getId();
         }
 
         return $this->customerGroupsByCode[$code];
     }
private function checkGroup(\Magento\Catalog\Api\Data\TierPriceInterface $price, $key, Result $validationResult)
     {
         $customerGroup = strtolower($price->getCustomerGroup());
 
         if ($customerGroup != $this->allGroupsValue && false === $this->retrieveGroupValue($customerGroup)) {
             $validationResult->addFailedItem(
                 $key,
                 __(
                     'No such entity with Customer Group = %customerGroup. '
                     . 'Row ID: SKU = %SKU, Website ID: %websiteId, Customer Group: %customerGroup, Quantity: %qty.',
                     [
                         'SKU' => '%SKU',
                         'websiteId' => '%websiteId',
                         'customerGroup' => '%customerGroup',
                         'qty' => '%qty'
                     ]
                 ),
                 [
                     'SKU' => $price->getSku(),
                     'websiteId' => $price->getWebsiteId(),
                     'customerGroup' => $price->getCustomerGroup(),
                     'qty' => $price->getQuantity()
                 ]
             );
         }
     }

Here is how i build the TierPriceInterface array:

$objTierPriceInterface = $objectManager->create('\Magento\Catalog\Api\Data\TierPriceInterface');
						$objTierPriceInterface->setPrice($arrCsvLine[$iPriceIndex]);
						$objTierPriceInterface->setPriceType('fixed');
						$objTierPriceInterface->setWebsiteId(1);
						$objTierPriceInterface->setSku($csvdata_sSku);
						$objTierPriceInterface->setCustomerGroup('32000');
						$objTierPriceInterface->setQuantity($arrCsvLine[$iQtyIndex]);
						$arrTieredPriceInterfaces[] = $objTierPriceInterface;

 For validation of customerGroup to fail, "32000" would have to not match:

$this->AllGroupsValue

Oh wtf. AllGroupsValue = "all groups".  It's weird they didn't use group id.

Now there is no error when adding the tiered prices but they don't show up for that product now, when you go to catalog/product/advanced pricing.