Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion app/code/Magento/Catalog/Controller/Product/Compare/Add.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,14 @@ public function execute()
$productName = $this->_objectManager->get(
\Magento\Framework\Escaper::class
)->escapeHtml($product->getName());
$this->messageManager->addSuccess(__('You added product %1 to the comparison list.', $productName));
$this->messageManager->addComplexSuccessMessage(
'addCompareSuccessMessage',
[
'product_name' => $productName,
'compare_list_url' => $this->_url->getUrl('catalog/product_compare')
]
);

$this->_eventManager->dispatch('catalog_product_compare_add_product', ['product' => $product]);
}

Expand Down
12 changes: 12 additions & 0 deletions app/code/Magento/Catalog/etc/frontend/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@
<argument name="typeId" xsi:type="string">recently_compared_product</argument>
</arguments>
</virtualType>
<type name="Magento\Framework\View\Element\Message\MessageConfigurationsPool">
<arguments>
<argument name="configurationsMap" xsi:type="array">
<item name="addCompareSuccessMessage" xsi:type="array">
<item name="renderer" xsi:type="const">\Magento\Framework\View\Element\Message\Renderer\BlockRenderer::CODE</item>
<item name="data" xsi:type="array">
<item name="template" xsi:type="string">Magento_Catalog::messages/addCompareSuccessMessage.phtml</item>
</item>
</item>
</argument>
</arguments>
</type>
<type name="Magento\Framework\App\ResourceConnection">
<plugin name="get_catalog_category_product_index_table_name" type="Magento\Catalog\Model\Indexer\Category\Product\Plugin\TableResolver"/>
</type>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
// @codingStandardsIgnoreFile
/** @var \Magento\Framework\View\Element\Template $block */
?>
<?= $block->escapeHtml(__(
'You added product %1 to the <a href="%2">comparison list</a>.',
$block->getData('product_name'),
$block->getData('compare_list_url')),
['a']
);
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function testAddAction()
);

$this->assertSessionMessages(
$this->equalTo(['You added product Simple Product 1 Name to the comparison list.']),
$this->equalTo(['You added product Simple Product 1 Name to the <a href="http://localhost/index.php/catalog/product_compare/">comparison list</a>.']),
MessageInterface::TYPE_SUCCESS
);

Expand Down