Skip to content

Commit 346f3fc

Browse files
committed
ACP2E-2522: Block Content not rendering in PDP meta description
1 parent dda5ede commit 346f3fc

File tree

2 files changed

+6
-6
lines changed
  • app/code/Magento/Catalog/Helper/Product
  • dev/tests/integration/testsuite/Magento/Catalog/Helper/Product

2 files changed

+6
-6
lines changed

app/code/Magento/Catalog/Helper/Product/View.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,7 @@ private function preparePageMetadata(ResultPage $resultPage, $product)
130130
$pageConfig->setKeywords($product->getName());
131131
}
132132

133-
$description = $product->getMetaDescription() ?: $product->getName();
134-
$pageConfig->setDescription($description);
133+
$pageConfig->setDescription($product->getMetaDescription());
135134

136135
if ($this->_catalogProduct->canUseCanonicalTag()) {
137136
$pageConfig->addRemotePageAsset(

dev/tests/integration/testsuite/Magento/Catalog/Helper/Product/ViewTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ public function testProductMetaDescriptionShouldBeRenderedAsIs()
169169
}
170170

171171
/**
172-
* If the product meta description is empty, it should be substituted with the product name
172+
* If the product meta description is empty, it should not be substituted with any other data and should not be
173+
* rendered on the product HTML sources
173174
*
174175
* @return void
175176
* @throws LocalizedException
@@ -182,7 +183,7 @@ public function testProductMetaDescriptionShouldBeRenderedAsIs()
182183
public function testEmptyProductMetaDescriptionShouldNotBeSubstitutedAndRendered()
183184
{
184185
$product = $this->fixtures->get('p1');
185-
$metaDescription = sprintf('<meta name="description" content="%s"/>', $product->getName());
186+
$metaDescription = '<meta name="description" content="';
186187

187188
$this->objectManager->get(\Magento\Framework\App\RequestInterface::class)->setParam('id', $product->getId());
188189
$this->_helper->prepareAndRender($this->page, $product->getId(), $this->_controller);
@@ -193,10 +194,10 @@ public function testEmptyProductMetaDescriptionShouldNotBeSubstitutedAndRendered
193194
$this->page->renderResult($response);
194195

195196
$this->assertNotEmpty($response->getBody());
196-
$this->assertStringContainsStringIgnoringCase(
197+
$this->assertStringNotContainsStringIgnoringCase(
197198
$metaDescription,
198199
$response->getBody(),
199-
'Empty meta description should be substituted with the product name'
200+
'Empty meta description should not be substituted or rendered'
200201
);
201202
}
202203

0 commit comments

Comments
 (0)