From c8e489fc35bd38afd7d21d434bfd63aa87d68e8e Mon Sep 17 00:00:00 2001 From: Tiago Sampaio Date: Mon, 18 May 2020 10:58:08 -0300 Subject: [PATCH] Adjustments. --- .../Frenet/Shipping/Helper/Objects.php | 1 - .../Model/Catalog/Product/View/Quote.php | 14 ++++- .../Product/View/Rate/Request/Builder.php | 2 +- .../controllers/ProductController.php | 8 +-- .../shipping/catalog/product/view/quote.phtml | 56 ++++++++++++++++++- 5 files changed, 72 insertions(+), 9 deletions(-) diff --git a/app/code/community/Frenet/Shipping/Helper/Objects.php b/app/code/community/Frenet/Shipping/Helper/Objects.php index 2ad3770..c826df9 100644 --- a/app/code/community/Frenet/Shipping/Helper/Objects.php +++ b/app/code/community/Frenet/Shipping/Helper/Objects.php @@ -1,5 +1,4 @@ load($productId); + + if (!$product || !$product->getId()) { + Mage::throwException("Product ID '{$productId}' does not exist."); + } } catch (Exception $exception) { - Mage::log('Product ID %s does not exist.', $productId); + Mage::log($exception->getMessage()); return []; } @@ -84,7 +94,7 @@ public function quoteByProductSku($sku, $postcode, $qty = 1, array $options = [] /** * @inheritDoc */ - private function quote(Product $product, string $postcode, int $qty = 1, $options = []) + private function quote(Product $product, $postcode, $qty = 1, $options = []) { /** @var RateRequest $rateRequest */ $rateRequest = $this->rateRequestBuilder->build($product, $postcode, $qty, $options); diff --git a/app/code/community/Frenet/Shipping/Model/Catalog/Product/View/Rate/Request/Builder.php b/app/code/community/Frenet/Shipping/Model/Catalog/Product/View/Rate/Request/Builder.php index ce9785b..2e17e96 100644 --- a/app/code/community/Frenet/Shipping/Model/Catalog/Product/View/Rate/Request/Builder.php +++ b/app/code/community/Frenet/Shipping/Model/Catalog/Product/View/Rate/Request/Builder.php @@ -110,7 +110,7 @@ private function fixQuoteItems(Mage_Sales_Model_Quote $quote) * * @return float */ - private function getItemRowWeight(QuoteItem $item, $qty) : float + private function getItemRowWeight(QuoteItem $item, $qty) { $this->dimensionsExtractor->setProductByCartItem($item); $weight = $this->dimensionsExtractor->getWeight(); diff --git a/app/code/community/Frenet/Shipping/controllers/ProductController.php b/app/code/community/Frenet/Shipping/controllers/ProductController.php index bbd4799..5f1a086 100644 --- a/app/code/community/Frenet/Shipping/controllers/ProductController.php +++ b/app/code/community/Frenet/Shipping/controllers/ProductController.php @@ -16,10 +16,10 @@ protected function _construct() public function quoteAction() { - $productId = (int) $this->getRequest()->getParam('product'); - $postcode = (string) $this->getRequest()->getParam('postcode'); - $qty = (float) $this->getRequest()->getParam('qty'); - $options = (array) $this->getRequest()->getParams(); + $productId = (int) $this->getRequest()->getPost('product'); + $postcode = (string) $this->getRequest()->getPost('postcode'); + $qty = (float) $this->getRequest()->getPost('qty'); + $options = (array) $this->getRequest()->getPost(); $this->getResponse()->setHeader('Content-type', 'application/json', true); diff --git a/app/design/frontend/base/default/template/frenet/shipping/catalog/product/view/quote.phtml b/app/design/frontend/base/default/template/frenet/shipping/catalog/product/view/quote.phtml index 9a34ddc..8034db6 100644 --- a/app/design/frontend/base/default/template/frenet/shipping/catalog/product/view/quote.phtml +++ b/app/design/frontend/base/default/template/frenet/shipping/catalog/product/view/quote.phtml @@ -49,7 +49,7 @@ $product = $this->getProduct();
-
@@ -91,4 +91,58 @@ $product = $this->getProduct(); +