示例#1
0
 /**
  * Retrieve add to cart url
  *
  * @param Product $product
  * @return string
  */
 public function getAddToCartUrl($product)
 {
     $beforeCompareUrl = $this->_catalogSession->getBeforeCompareUrl();
     $params = array('product' => $product->getId(), \Magento\Framework\App\Action\Action::PARAM_NAME_URL_ENCODED => $this->getEncodedUrl($beforeCompareUrl));
     return $this->_getUrl('checkout/cart/add', $params);
 }
示例#2
0
 /**
  * Retrieve add to cart url
  *
  * @param Product $product
  * @return string
  */
 public function getAddToCartUrl($product)
 {
     $beforeCompareUrl = $this->_catalogSession->getBeforeCompareUrl();
     $params = ['product' => $product->getId(), \Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED => $this->getEncodedUrl($beforeCompareUrl), '_secure' => $this->_getRequest()->isSecure()];
     return $this->_getUrl('checkout/cart/add', $params);
 }