Skip to content

Commit 780f3bd

Browse files
committed
SUPEE-7245: Add To Cart issue on Compare Products Page when enabling SSL using the blank theme
- Merge of solution MAGETWO-42776
1 parent 5011ce6 commit 780f3bd

File tree

4 files changed

+7
-0
lines changed

4 files changed

+7
-0
lines changed

app/code/Magento/Catalog/view/frontend/templates/product/compare/list.phtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
<div class="actions-primary">
6666
<?php if ($_item->isSaleable()): ?>
6767
<form data-role="tocart-form" action="<?php echo $this->helper('Magento\Catalog\Helper\Product\Compare')->getAddToCartUrl($_item); ?>" method="post">
68+
<?php echo $block->getBlockHtml('formkey')?>
6869
<button type="submit" class="action tocart primary">
6970
<span><?php echo __('Add to Cart'); ?></span>
7071
</button>

app/code/Magento/Catalog/view/frontend/templates/product/list.phtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ $imageBlock = $block->getLayout()->createBlock('Magento\Catalog\Block\Product\I
7979
<form data-role="tocart-form" action="<?php echo $postParams['action']; ?>" method="post">
8080
<input type="hidden" name="product" value="<?php echo $postParams['data']['product']; ?>">
8181
<input type="hidden" name="<?php echo Action::PARAM_NAME_URL_ENCODED; ?>" value="<?php echo $postParams['data'][Action::PARAM_NAME_URL_ENCODED]; ?>">
82+
<?php echo $block->getBlockHtml('formkey')?>
8283
<button type="submit"
8384
title="<?php echo $block->escapeHtml(__('Add to Cart')); ?>"
8485
class="action tocart primary">

app/code/Magento/Catalog/view/frontend/templates/product/view/form.phtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<input type="hidden" name="product" value="<?php echo $_product->getId() ?>" />
2222
<input type="hidden" name="selected_configurable_option" value="" />
2323
<input type="hidden" name="related_product" id="related-products-field" value="" />
24+
<?php echo $block->getBlockHtml('formkey')?>
2425
<?php echo $block->getChildHtml('form_top'); ?>
2526
<?php if (!$block->hasOptions()):?>
2627
<?php echo $block->getChildHtml('product_info_form_content'); ?>

app/code/Magento/Checkout/Controller/Cart/Add.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ protected function _initProduct()
7979
*/
8080
public function execute()
8181
{
82+
if (!$this->_formKeyValidator->validate($this->getRequest())) {
83+
return $this->resultRedirectFactory->create()->setPath('*/*/');
84+
}
85+
8286
$params = $this->getRequest()->getParams();
8387
try {
8488
if (isset($params['qty'])) {

0 commit comments

Comments
 (0)