File tree Expand file tree Collapse file tree 4 files changed +7
-0
lines changed
Catalog/view/frontend/templates/product Expand file tree Collapse file tree 4 files changed +7
-0
lines changed Original file line number Diff line number Diff line change 65
65
<div class="actions-primary">
66
66
<?php if ($ _item ->isSaleable ()): ?>
67
67
<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 ' )?>
68
69
<button type="submit" class="action tocart primary">
69
70
<span><?php echo __ ('Add to Cart ' ); ?> </span>
70
71
</button>
Original file line number Diff line number Diff line change @@ -79,6 +79,7 @@ $imageBlock = $block->getLayout()->createBlock('Magento\Catalog\Block\Product\I
79
79
<form data-role="tocart-form" action="<?php echo $ postParams ['action ' ]; ?> " method="post">
80
80
<input type="hidden" name="product" value="<?php echo $ postParams ['data ' ]['product ' ]; ?> ">
81
81
<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 ' )?>
82
83
<button type="submit"
83
84
title="<?php echo $ block ->escapeHtml (__ ('Add to Cart ' )); ?> "
84
85
class="action tocart primary">
Original file line number Diff line number Diff line change 21
21
<input type="hidden" name="product" value="<?php echo $ _product ->getId () ?> " />
22
22
<input type="hidden" name="selected_configurable_option" value="" />
23
23
<input type="hidden" name="related_product" id="related-products-field" value="" />
24
+ <?php echo $ block ->getBlockHtml ('formkey ' )?>
24
25
<?php echo $ block ->getChildHtml ('form_top ' ); ?>
25
26
<?php if (!$ block ->hasOptions ()):?>
26
27
<?php echo $ block ->getChildHtml ('product_info_form_content ' ); ?>
Original file line number Diff line number Diff line change @@ -79,6 +79,10 @@ protected function _initProduct()
79
79
*/
80
80
public function execute ()
81
81
{
82
+ if (!$ this ->_formKeyValidator ->validate ($ this ->getRequest ())) {
83
+ return $ this ->resultRedirectFactory ->create ()->setPath ('*/*/ ' );
84
+ }
85
+
82
86
$ params = $ this ->getRequest ()->getParams ();
83
87
try {
84
88
if (isset ($ params ['qty ' ])) {
You can’t perform that action at this time.
0 commit comments