From 50f92c6c72f24ed222eb1aa8d579f33115a6872d Mon Sep 17 00:00:00 2001 From: pini-girit Date: Mon, 24 Feb 2020 14:45:46 +0200 Subject: [PATCH 1/9] Added page-builder support and applied yotpo.refreshWidgets() for supporting dynamic contents --- Plugin/AbstractYotpoReviewsSummary.php | 16 +++++++++++++++- Plugin/Review/Block/Product/ReviewRenderer.php | 15 ++++++--------- view/frontend/web/css/source/_module.less | 4 ++-- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/Plugin/AbstractYotpoReviewsSummary.php b/Plugin/AbstractYotpoReviewsSummary.php index 0d393483..28416f90 100644 --- a/Plugin/AbstractYotpoReviewsSummary.php +++ b/Plugin/AbstractYotpoReviewsSummary.php @@ -3,6 +3,7 @@ namespace Yotpo\Yotpo\Plugin; use Magento\Catalog\Model\Product; +use Magento\Framework\Registry; use Magento\Framework\View\Element\Context; use Yotpo\Yotpo\Model\Config as YotpoConfig; @@ -18,12 +19,25 @@ class AbstractYotpoReviewsSummary */ protected $_yotpoConfig; + /** + * @var Registry + */ + protected $_coreRegistry; + + /** + * @method __construct + * @param Context $context + * @param YotpoConfig $yotpoConfig + * @param Registry $coreRegistry + */ public function __construct( Context $context, - YotpoConfig $yotpoConfig + YotpoConfig $yotpoConfig, + Registry $coreRegistry ) { $this->_context = $context; $this->_yotpoConfig = $yotpoConfig; + $this->_coreRegistry = $coreRegistry; } protected function _getCategoryBottomLineHtml(Product $product) diff --git a/Plugin/Review/Block/Product/ReviewRenderer.php b/Plugin/Review/Block/Product/ReviewRenderer.php index 0e3a8b86..6ae3a1c0 100644 --- a/Plugin/Review/Block/Product/ReviewRenderer.php +++ b/Plugin/Review/Block/Product/ReviewRenderer.php @@ -32,18 +32,15 @@ public function aroundGetReviewsSummaryHtml( return $proceed($product, $templateType, $displayIfNoReviews); } - $currentPage = $this->_context->getRequest()->getFullActionName(); - - if ($this->_yotpoConfig->isCategoryBottomlineEnabled()) { - if (in_array($currentPage, ['cms_index_index', 'catalog_category_view'])) { + $currentProduct = $this->_coreRegistry->registry('current_product'); + if (!$currentProduct || $currentProduct->getId() !== $product->getId()) { + if ($this->_yotpoConfig->isCategoryBottomlineEnabled()) { return $this->_getCategoryBottomLineHtml($product); - } - } elseif (!$this->_yotpoConfig->isMdrEnabled()) { - if (in_array($currentPage, ['cms_index_index', 'catalog_category_view'])) { + } elseif (!$this->_yotpoConfig->isMdrEnabled()) { return $proceed($product, $templateType, $displayIfNoReviews); } - } else { - return ''; } + + return ''; } } diff --git a/view/frontend/web/css/source/_module.less b/view/frontend/web/css/source/_module.less index c98e988b..e6793401 100644 --- a/view/frontend/web/css/source/_module.less +++ b/view/frontend/web/css/source/_module.less @@ -27,14 +27,14 @@ margin: 0 10px 1px 0; } - &.cms-index-index .product-item-actions { + .product-item .product-item-actions { margin-top: 5px !important; } &.catalog-category-view, &.catalog-product-view { &.page-products { - .product-item-actions { + .product-item .product-item-actions { margin-top: 0 !important; } } From 4627aa397adee53e07ba2cd2f13b173040f44a08 Mon Sep 17 00:00:00 2001 From: pini-girit Date: Wed, 11 Mar 2020 17:44:55 +0200 Subject: [PATCH 2/9] Added CSP whitelist --- etc/config.xml | 10 ++++++++++ etc/csp_whitelist.xml | 10 ++++++++++ 2 files changed, 20 insertions(+) create mode 100644 etc/csp_whitelist.xml diff --git a/etc/config.xml b/etc/config.xml index 74729268..357844b8 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -18,5 +18,15 @@ 50 + + + + 1 + + + 1 + + + diff --git a/etc/csp_whitelist.xml b/etc/csp_whitelist.xml new file mode 100644 index 00000000..a7288f3f --- /dev/null +++ b/etc/csp_whitelist.xml @@ -0,0 +1,10 @@ + + + + + + yotpo.com + + + + From d894dc8ce7c4124120c617dff34b1da4469a54cf Mon Sep 17 00:00:00 2001 From: pini-girit Date: Thu, 12 Mar 2020 10:29:14 +0200 Subject: [PATCH 3/9] Added support for custom brand attribute with type dropdown --- Model/Schema.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Model/Schema.php b/Model/Schema.php index ec6f1604..bf92b4c7 100644 --- a/Model/Schema.php +++ b/Model/Schema.php @@ -110,7 +110,7 @@ private function prepareProductsData(Order $order) 'upc' => $product->getUpc(), 'isbn' => $product->getIsbn(), 'mpn' => $product->getMpn(), - 'brand' => $product->getBrand(), + 'brand' => $product->getBrand() ? $product->getAttributeText('brand') : null, ] ), ]; From 1c01e1254d3bb2046f0796b668d777edfc206b7d Mon Sep 17 00:00:00 2001 From: pini-girit Date: Wed, 11 Mar 2020 17:44:55 +0200 Subject: [PATCH 4/9] Added CSP whitelist --- etc/csp_whitelist.xml | 51 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/etc/csp_whitelist.xml b/etc/csp_whitelist.xml index a7288f3f..97af7373 100644 --- a/etc/csp_whitelist.xml +++ b/etc/csp_whitelist.xml @@ -3,7 +3,56 @@ - yotpo.com + yotpo.com + www.yotpo.com + p.yotpo.com + staticw2.yotpo.com + w2.yotpo.com + + + + + yotpo.com + www.yotpo.com + p.yotpo.com + staticw2.yotpo.com + w2.yotpo.com + + + + + yotpo.com + www.yotpo.com + p.yotpo.com + staticw2.yotpo.com + w2.yotpo.com + + + + + yotpo.com + www.yotpo.com + p.yotpo.com + staticw2.yotpo.com + w2.yotpo.com + + + + + yotpo.com + www.yotpo.com + p.yotpo.com + staticw2.yotpo.com + w2.yotpo.com + + + + + yotpo.com + www.yotpo.com + p.yotpo.com + staticw2.yotpo.com + w2.yotpo.com From a321832263156ca5476286e0f49a058c688e5232 Mon Sep 17 00:00:00 2001 From: pini-girit Date: Tue, 31 Mar 2020 18:07:27 +0300 Subject: [PATCH 5/9] On order sync - exclude fully canceled items and substract the amount_refunded from the price field --- Model/Schema.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Model/Schema.php b/Model/Schema.php index bf92b4c7..71b0c054 100644 --- a/Model/Schema.php +++ b/Model/Schema.php @@ -95,15 +95,22 @@ private function prepareProductsData(Order $order) if (!($product && $product->getId())) { continue; } + if ( + $orderItem->getData('amount_refunded') >= $orderItem->getData('row_total_incl_tax') || + $orderItem->getData('qty_ordered') <= ($orderItem->getData('qty_refunded') + $orderItem->getData('qty_canceled')) + ) { + //Skip if item is fully canceled or refunded + continue; + } if ($orderItem->getProductType() === ProductTypeGrouped::TYPE_CODE && isset($productsData[$product->getId()])) { - $productsData[$product->getId()]['price'] += $orderItem->getData('row_total_incl_tax'); + $productsData[$product->getId()]['price'] += $orderItem->getData('row_total_incl_tax') - $orderItem->getData('amount_refunded'); } else { $productsData[$product->getId()] = [ 'name' => $product->getName(), 'url' => $product->getProductUrl(), 'image' => $this->getProductMainImageUrl($product), 'description' => $this->escaper->escapeHtml(strip_tags($product->getDescription())), - 'price' => $orderItem->getData('row_total_incl_tax'), + 'price' => $orderItem->getData('row_total_incl_tax') - $orderItem->getData('amount_refunded'), 'specs' => array_filter( [ 'external_sku' => $product->getSku(), From 925297801b3bb64b5d6a554295bad1f6aa0311e8 Mon Sep 17 00:00:00 2001 From: pini-girit Date: Tue, 7 Apr 2020 14:30:57 +0300 Subject: [PATCH 6/9] Changed cron class UpdateMetadata to UpdateMetadataJob to align with it's class name. Should solve GH issue #228 --- Cron/{UpdateMetadata.php => UpdateMetadataJob.php} | 0 etc/crontab.xml | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename Cron/{UpdateMetadata.php => UpdateMetadataJob.php} (100%) diff --git a/Cron/UpdateMetadata.php b/Cron/UpdateMetadataJob.php similarity index 100% rename from Cron/UpdateMetadata.php rename to Cron/UpdateMetadataJob.php diff --git a/etc/crontab.xml b/etc/crontab.xml index f350c09c..624bebb9 100644 --- a/etc/crontab.xml +++ b/etc/crontab.xml @@ -4,7 +4,7 @@ * * * * * - + 30 2 * * * From 801c343e5861ba65ed8ad703e8fe281561574bbb Mon Sep 17 00:00:00 2001 From: pini-girit Date: Thu, 16 Apr 2020 09:48:17 +0300 Subject: [PATCH 7/9] GS-2034,YOTPO-170: Added a custom log file, yotpo_yotpo.log, in addition to what comes with Magento --- Model/Config.php | 12 +++++++++++- Model/Logger.php | 6 ++++++ Model/Logger/YotpoHandler.php | 19 +++++++++++++++++++ etc/di.xml | 16 +++++++++++++++- 4 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 Model/Logger.php create mode 100644 Model/Logger/YotpoHandler.php diff --git a/Model/Config.php b/Model/Config.php index 836748f3..62c0aa46 100644 --- a/Model/Config.php +++ b/Model/Config.php @@ -13,6 +13,7 @@ use Magento\Store\Model\ScopeInterface; use Magento\Store\Model\StoreManagerInterface; use Psr\Log\LoggerInterface; +use Yotpo\Yotpo\Model\Logger as YotpoLogger; class Config { @@ -79,6 +80,11 @@ class Config */ private $logger; + /** + * @var YotpoLogger + */ + private $yotpoLogger; + /** * @method __construct * @param StoreManagerInterface $storeManager @@ -89,6 +95,7 @@ class Config * @param ModuleListInterface $moduleList * @param ProductMetadataInterface $productMetadata * @param LoggerInterface $logger + * @param YotpoLogger $yotpoLogger */ public function __construct( StoreManagerInterface $storeManager, @@ -98,7 +105,8 @@ public function __construct( DateTimeFactory $datetimeFactory, ModuleListInterface $moduleList, ProductMetadataInterface $productMetadata, - LoggerInterface $logger + LoggerInterface $logger, + YotpoLogger $yotpoLogger ) { $this->storeManager = $storeManager; $this->scopeConfig = $scopeConfig; @@ -108,6 +116,7 @@ public function __construct( $this->moduleList = $moduleList; $this->productMetadata = $productMetadata; $this->logger = $logger; + $this->yotpoLogger = $yotpoLogger; } /** @@ -398,6 +407,7 @@ public function log($message, $type = "debug", $data = [], $prefix = '[Yotpo Log $this->logger->debug($prefix . json_encode($message), $data); break; } + $this->yotpoLogger->info($prefix . json_encode($message), $data); } return $this; } diff --git a/Model/Logger.php b/Model/Logger.php new file mode 100644 index 00000000..31797cc2 --- /dev/null +++ b/Model/Logger.php @@ -0,0 +1,6 @@ + - \ No newline at end of file + + + + Magento\Framework\Filesystem\Driver\File + + + + + yotpoLogger + + Yotpo\Yotpo\Model\Logger\YotpoHandler + + + + From 8f94011b5bcf560f8aff84ae751edf4bc9f7c2a8 Mon Sep 17 00:00:00 2001 From: pini-girit Date: Mon, 27 Apr 2020 11:25:58 +0300 Subject: [PATCH 8/9] GS-1995,YOTPO-168: Removed unused Cron classes & pointed 'yotpo_yotpo_update_metadata' to the corresponding Model\Jobs\UpdateMetadata --- Cron/OrdersSyncJob.php | 24 ------------------------ Cron/UpdateMetadataJob.php | 24 ------------------------ etc/crontab.xml | 2 +- 3 files changed, 1 insertion(+), 49 deletions(-) delete mode 100644 Cron/OrdersSyncJob.php delete mode 100644 Cron/UpdateMetadataJob.php diff --git a/Cron/OrdersSyncJob.php b/Cron/OrdersSyncJob.php deleted file mode 100644 index 223bd531..00000000 --- a/Cron/OrdersSyncJob.php +++ /dev/null @@ -1,24 +0,0 @@ -ordersSyncModel = $ordersSyncModel; - } - - public function execute() - { - return $this->ordersSyncModel->execute(); - } -} diff --git a/Cron/UpdateMetadataJob.php b/Cron/UpdateMetadataJob.php deleted file mode 100644 index 46f761c3..00000000 --- a/Cron/UpdateMetadataJob.php +++ /dev/null @@ -1,24 +0,0 @@ -updateMetadataModel = $updateMetadataModel; - } - - public function execute() - { - return $this->updateMetadataModel->execute(); - } -} diff --git a/etc/crontab.xml b/etc/crontab.xml index 624bebb9..f350c09c 100644 --- a/etc/crontab.xml +++ b/etc/crontab.xml @@ -4,7 +4,7 @@ * * * * * - + 30 2 * * * From 213e3a1232b66bc6df4fe9cccd7a571d465dd195 Mon Sep 17 00:00:00 2001 From: lgreenboim Date: Sun, 3 May 2020 13:16:15 +0300 Subject: [PATCH 9/9] upgrad version to 3.1.1 --- composer.json | 2 +- etc/module.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 15f913f2..dedc7ebb 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "yotpo/module-review", "description": "Yotpo Reviews extension for Magento2", - "version": "3.1.0", + "version": "3.1.1", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/etc/module.xml b/etc/module.xml index fbda0305..111c3f78 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,6 +1,6 @@ - +