Skip to content

Commit

Permalink
pass full error message text
Browse files Browse the repository at this point in the history
  • Loading branch information
engcom-Charlie committed Jan 4, 2021
1 parent 8fccf46 commit 287084c
Showing 1 changed file with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ private function retrieveValidPrices(array $prices)

foreach ($prices as $key => $price) {
if (!$price->getSku() || in_array($price->getSku(), $failedSkus)) {
$errorMessage = 'The product that was requested doesn\'t exist. Verify the product and try again.';
$errorMessage = 'The product that was requested doesn\'t exist. Verify the product and try again. '
. 'Row ID: SKU = %SKU, Store ID: %storeId, Price From: %priceFrom, Price To: %priceTo.';
$this->addFailedItemPrice($price, $key, $errorMessage, []);
}
$this->checkStore($price, $key);
Expand All @@ -184,14 +185,16 @@ private function retrieveValidPrices(array $prices)
private function checkStore(SpecialPriceInterface $price, int $key): void
{
if ($this->catalogData->isPriceGlobal() && $price->getStoreId() !== 0) {
$errorMessage = 'Could not change non global Price when price scope is global.';
$errorMessage = 'Could not change non global Price when price scope is global. '
. 'Row ID: SKU = %SKU, Store ID: %storeId, Price From: %priceFrom, Price To: %priceTo.';
$this->addFailedItemPrice($price, $key, $errorMessage, []);
}

try {
$this->storeRepository->getById($price->getStoreId());
} catch (NoSuchEntityException $e) {
$errorMessage = 'Requested store is not found.';
$errorMessage = 'Requested store is not found. '
. 'Row ID: SKU = %SKU, Store ID: %storeId, Price From: %priceFrom, Price To: %priceTo.';
$this->addFailedItemPrice($price, $key, $errorMessage, []);
}
}
Expand All @@ -208,7 +211,8 @@ private function checkStore(SpecialPriceInterface $price, int $key): void
private function checkDate(SpecialPriceInterface $price, $value, $label, $key)
{
if ($value && !$this->isCorrectDateValue($value)) {
$errorMessage = 'Invalid attribute %label = %priceTo.';
$errorMessage = 'Invalid attribute %label = %priceTo. '
. 'Row ID: SKU = %SKU, Store ID: %storeId, Price From: %priceFrom, Price To: %priceTo.';
$this->addFailedItemPrice($price, $key, $errorMessage, ['label' => $label]);
}
}
Expand All @@ -226,7 +230,8 @@ private function checkDate(SpecialPriceInterface $price, $value, $label, $key)
private function checkPrice(SpecialPriceInterface $price, int $key): void
{
if (null === $price->getPrice() || $price->getPrice() < 0) {
$errorMessage = 'Invalid attribute Price = %price.';
$errorMessage = 'Invalid attribute Price = %price. '
. 'Row ID: SKU = %SKU, Store ID: %storeId, Price From: %priceFrom, Price To: %priceTo.';
$this->addFailedItemPrice($price, $key, $errorMessage, ['price' => $price->getPrice()]);
}
}
Expand Down Expand Up @@ -256,14 +261,7 @@ private function addFailedItemPrice(
$additionalInfo['priceFrom'] = $price->getPriceFrom();
$additionalInfo['priceTo'] = $price->getPriceTo();

$this->validationResult->addFailedItem(
$key,
__(
$message . ' Row ID: SKU = %SKU, Store ID: %storeId, Price From: %priceFrom, Price To: %priceTo.',
$additionalInfo
),
$additionalInfo
);
$this->validationResult->addFailedItem($key, __($message, $additionalInfo), $additionalInfo);
}

/**
Expand Down

0 comments on commit 287084c

Please sign in to comment.