Skip to content

Commit

Permalink
Merge pull request #294 from YotpoLtd/YOTP-449-fix-description-strip-…
Browse files Browse the repository at this point in the history
…tags-with-null

YOTP-449 fix description strip tags with null
  • Loading branch information
LiorGingi authored May 3, 2023
2 parents 39713a5 + f7c10b6 commit 0fa4438
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Model/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,20 @@ private function getProductMainImageUrl(Product $product)
return "";
}

public function getProductDescription(Product $product)
{
$shortDescription = $product->getShortDescription();
if ($shortDescription) {
$descriptionWithStrippedTags = strip_tags($shortDescription);

if ($descriptionWithStrippedTags) {
return $this->escaper->escapeHtml($descriptionWithStrippedTags);
}
}

return null;
}

/**
* @method prepareProductsData
* @param Order $order
Expand Down Expand Up @@ -107,11 +121,12 @@ private function prepareProductsData(Order $order)
if ($orderItem->getProductType() === ProductTypeGrouped::TYPE_CODE && isset($productsData[$product->getId()])) {
$productsData[$product->getId()]['price'] += $orderItem->getData('row_total_incl_tax') - $orderItem->getData('amount_refunded');
} else {

$productsData[$product->getId()] = [
'name' => $product->getName(),
'url' => $product->getProductUrl(),
'image' => $this->getProductMainImageUrl($product),
'description' => $this->escaper->escapeHtml(strip_tags($product->getDescription())),
'description' => $this->getProductDescription($product),
'price' => $orderItem->getData('row_total_incl_tax') - $orderItem->getData('amount_refunded'),
'specs' => array_filter(
[
Expand Down

0 comments on commit 0fa4438

Please sign in to comment.