Skip to content

Commit

Permalink
Merge pull request #71 from trustpilot/new-release
Browse files Browse the repository at this point in the history
2.6.546
  • Loading branch information
dukeimg committed Mar 30, 2020
2 parents b680672 + c8387ba commit 6680549
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
12 changes: 10 additions & 2 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -37,6 +38,7 @@ class Data extends AbstractHelper
protected $_registry;
protected $_linkManagement;
protected $_trustpilotLog;
protected $_url;

public function __construct(
Context $context,
Expand All @@ -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;
Expand All @@ -68,6 +71,7 @@ public function __construct(
$this->_registry = $registry;
$this->_linkManagement = $linkManagement;
$this->_trustpilotLog = $trustpilotLog;
$this->_url = $url;
}

public function getIntegrationAppUrl()
Expand Down Expand Up @@ -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) {
Expand Down
17 changes: 15 additions & 2 deletions Helper/OrderData.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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)[^>]*?>.*?</\\1>@si', '', $string);
$string = strip_tags($string);
if ($remove_breaks) {
$string = preg_replace('/[\r\n\t ]+/', ' ', $string);
}
return trim($string);
}
}
2 changes: 1 addition & 1 deletion Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
],
Expand All @@ -24,4 +24,4 @@
"Trustpilot\\Reviews\\": ""
}
}
}
}

0 comments on commit 6680549

Please sign in to comment.