From c8387ba71a0efd238f56c248d3d3db6cf5efae44 Mon Sep 17 00:00:00 2001 From: Viktor Danilov Date: Mon, 30 Mar 2020 08:50:33 +0300 Subject: [PATCH] 2.6.546 --- Helper/Data.php | 12 ++++++++++-- Helper/OrderData.php | 17 +++++++++++++++-- Model/Config.php | 2 +- composer.json | 4 ++-- 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/Helper/Data.php b/Helper/Data.php index e70de0b..72d4a87 100755 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -18,6 +18,7 @@ use \Magento\Framework\UrlInterface; use \Magento\Framework\Registry; use Magento\ConfigurableProduct\Api\LinkManagementInterface; +use \Magento\Framework\Url; class Data extends AbstractHelper { @@ -37,6 +38,7 @@ class Data extends AbstractHelper protected $_registry; protected $_linkManagement; protected $_trustpilotLog; + protected $_url; public function __construct( Context $context, @@ -51,7 +53,8 @@ public function __construct( ReinitableConfigInterface $reinitableConfig, Registry $registry, LinkManagementInterface $linkManagement, - TrustpilotLog $trustpilotLog + TrustpilotLog $trustpilotLog, + Url $url ) { $this->_storeManager = $storeManager; $this->_categoryCollectionFactory = $categoryCollectionFactory; @@ -68,6 +71,7 @@ public function __construct( $this->_registry = $registry; $this->_linkManagement = $linkManagement; $this->_trustpilotLog = $trustpilotLog; + $this->_url = $url; } public function getIntegrationAppUrl() @@ -254,7 +258,11 @@ public function getPageUrl($page, $scope, $storeId) return $productUrl; case 'trustpilot_trustbox_product': $product = $this->getFirstProduct('store', $storeId); - $productUrl = strtok($product->setStoreId($storeId)->getUrlInStore(),'?').'?___store='.$storeCode; + $productUrl = $this->_url->getUrl('catalog/product/view', [ + 'id' => $product->getId(), + '_nosid' => true, + '_query' => ['___store' => $storeCode] + ]); return $productUrl; } } catch (\Throwable $e) { diff --git a/Helper/OrderData.php b/Helper/OrderData.php index 8be4266..edb0c19 100755 --- a/Helper/OrderData.php +++ b/Helper/OrderData.php @@ -213,11 +213,12 @@ function getProductExtraFields($productData, $product, $childProducts, $order) { return array_merge($productData, array( 'price' => $product->getFinalPrice(), 'currency' => $order->getOrderCurrencyCode(), - 'description' => strip_tags($product->getDescription()), + 'description' => $this->stripAllTags($product->getDescription(), true), 'meta' => array( 'title' => $product->getMetaTitle() ? $product->getMetaTitle() : $product->getName(), 'keywords' => $product->getMetaKeyword() ? $product->getMetaKeyword() : $product->getName(), - 'description' => $product->getMetaDescription() ? $product->getMetaDescription() : substr(strip_tags($product->getDescription()), 0, 255), + 'description' => $product->getMetaDescription() ? + $product->getMetaDescription() : substr($this->stripAllTags($product->getDescription(), true), 0, 255), ), 'manufacturer' => $manufacturer ? $manufacturer : '', 'categories' => $this->getProductCategories($product, $childProducts), @@ -307,4 +308,16 @@ function getAllVideos($product, $childProducts = null) { return $videos; } + + function stripAllTags($string, $remove_breaks = false) { + if (gettype($string) != 'string') { + return ''; + } + $string = preg_replace('@<(script|style)[^>]*?>.*?@si', '', $string); + $string = strip_tags($string); + if ($remove_breaks) { + $string = preg_replace('/[\r\n\t ]+/', ' ', $string); + } + return trim($string); + } } diff --git a/Model/Config.php b/Model/Config.php index 37507d7..5310b21 100755 --- a/Model/Config.php +++ b/Model/Config.php @@ -16,7 +16,7 @@ class Config const TRUSTPILOT_GENERAL_CONFIGURATION = 'general'; const TRUSTPILOT_TRUSTBOX_CONFIGURATION = 'trustbox'; const TRUSTPILOT_INTEGRATION_KEY = 'key'; - const TRUSTPILOT_PLUGIN_VERSION = '2.6.542'; + const TRUSTPILOT_PLUGIN_VERSION = '2.6.546'; const TRUSTPILOT_SCRIPT = 'TrustpilotScriptUrl'; const TRUSTPILOT_INTEGRATION_APP = 'IntegrationAppUrl'; const TRUSTPILOT_WIDGET_SCRIPT = 'WidgetScriptUrl'; diff --git a/composer.json b/composer.json index 1858bda..08ca4d6 100755 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "trustpilot/module-reviews", "description": "The Trustpilot Review extension makes it simple and easy for merchants to collect reviews from their customers to power their marketing efforts, increase sales conversion, build their online reputation and draw business insights.", "type": "magento2-module", - "version": "2.6.542", + "version": "2.6.546", "license": [ "OSL-3.0" ], @@ -24,4 +24,4 @@ "Trustpilot\\Reviews\\": "" } } - } + } \ No newline at end of file