Beispiel #1
0
 public function testGetTargetStorePostData()
 {
     $store = $this->getMockBuilder('Magento\\Store\\Model\\Store')->disableOriginalConstructor()->getMock();
     $store->expects($this->any())->method('getCode')->will($this->returnValue('new-store'));
     $currentStore = $this->getMockBuilder('Magento\\Store\\Model\\Store')->disableOriginalConstructor()->getMock();
     $currentStore->expects($this->any())->method('getCode')->will($this->returnValue('current-store'));
     $this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue($currentStore));
     $this->corePostDataHelper->expects($this->any())->method('getPostData')->with(null, ['___store' => 'new-store', '___from_store' => 'current-store']);
     $this->switcher->getTargetStorePostData($store);
 }
Beispiel #2
0
 public function testGetAddToCartPostParams()
 {
     $url = 'http://localhost.com/dev/';
     $id = 1;
     $uenc = strtr(base64_encode($url), '+/=', '-_,');
     $data = ['product' => $id, \Magento\Framework\App\Action\Action::PARAM_NAME_URL_ENCODED => $uenc];
     $expectedPostData = json_encode(['action' => $url, 'data' => ['product' => $id, 'uenc' => $uenc]]);
     $this->typeInstanceMock->expects($this->once())->method('hasRequiredOptions')->with($this->equalTo($this->productMock))->will($this->returnValue(false));
     $this->cartHelperMock->expects($this->any())->method('getAddUrl')->with($this->equalTo($this->productMock), $this->equalTo([]))->will($this->returnValue($url));
     $this->productMock->expects($this->once())->method('getEntityId')->will($this->returnValue($id));
     $this->productMock->expects($this->once())->method('getTypeInstance')->will($this->returnValue($this->typeInstanceMock));
     $this->postDataHelperMock->expects($this->once())->method('getEncodedUrl')->with($this->equalTo($url))->will($this->returnValue($uenc));
     $this->postDataHelperMock->expects($this->once())->method('getPostData')->with($this->equalTo($url), $this->equalTo($data))->will($this->returnValue($expectedPostData));
     $result = $this->block->getAddToCartPostParams($this->productMock);
     $this->assertEquals($expectedPostData, $result);
 }
Beispiel #3
0
 /**
  * Retrieve params for updating product in wishlist
  *
  * @param \Magento\Catalog\Model\Product|\Magento\Wishlist\Model\Item $item
  *
  * @return  string|false
  */
 public function getUpdateParams($item)
 {
     $itemId = null;
     if ($item instanceof \Magento\Catalog\Model\Product) {
         $itemId = $item->getWishlistItemId();
         $productId = $item->getId();
     }
     if ($item instanceof \Magento\Wishlist\Model\Item) {
         $itemId = $item->getId();
         $productId = $item->getProduct()->getId();
     }
     $url = $this->_getUrl('wishlist/index/updateItemOptions');
     if ($itemId) {
         $params = array('id' => $itemId, 'product' => $productId);
         return $this->_postDataHelper->getPostData($url, $params);
     }
     return false;
 }
Beispiel #4
0
 /**
  * Get post parameters
  *
  * @param \Magento\Catalog\Model\Product $product
  * @return string
  */
 public function getAddToCartPostParams(\Magento\Catalog\Model\Product $product)
 {
     $url = $this->getAddToCartUrl($product);
     $data = ['product' => $product->getEntityId(), \Magento\Framework\App\Action\Action::PARAM_NAME_URL_ENCODED => $this->_postDataHelper->getEncodedUrl($url)];
     return $this->_postDataHelper->getPostData($url, $data);
 }
Beispiel #5
0
 /**
  * Retrieve params for post request
  *
  * @return string
  */
 public function getPostParams()
 {
     return $this->_postDataHelper->getPostData($this->getHref());
 }
Beispiel #6
0
 /**
  * Return POST data for currency to switch
  *
  * @param string $code
  * @return string
  */
 public function getSwitchCurrencyPostData($code)
 {
     return $this->_postDataHelper->getPostData($this->getSwitchUrl(), ['currency' => $code]);
 }
Beispiel #7
0
 /**
  * Returns target store post data
  *
  * @param \Magento\Store\Model\Store $store
  * @return string
  */
 public function getTargetStorePostData(\Magento\Store\Model\Store $store)
 {
     return $this->_postDataHelper->getPostData($this->getHomeUrl(), array('___store' => $store->getCode()));
 }
Beispiel #8
0
 /**
  * Retrieve widget options in json format
  *
  * @param array $customOptions Optional parameter for passing custom selectors from template
  * @return string
  */
 public function getWidgetOptionsJson(array $customOptions = array())
 {
     $postData = $this->_postDataHelper->getPostData($this->getPagerUrl(), array(\Magento\Framework\App\Action\Action::PARAM_NAME_URL_ENCODED => $this->getPagerEncodedUrl()));
     $options = array('modeCookie' => ToolbarModel::MODE_COOKIE_NAME, 'directionCookie' => ToolbarModel::DIRECTION_COOKIE_NAME, 'orderCookie' => ToolbarModel::ORDER_COOKIE_NAME, 'limitCookie' => ToolbarModel::LIMIT_COOKIE_NAME, 'postData' => json_decode($postData));
     $options = array_replace_recursive($options, $customOptions);
     return json_encode(array('productListToolbarForm' => $options));
 }