From 8f159f8b82867311f6f44fdb456aba63105aebc6 Mon Sep 17 00:00:00 2001 From: Ian Anderson Date: Wed, 23 Aug 2023 10:16:56 -0400 Subject: [PATCH 1/6] compatibility and syntax fixes --- Logger/Logger.php | 2 +- Model/XMLWriter.php | 17 ++++++++--------- ViewModel/Pixel.php | 4 ++-- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Logger/Logger.php b/Logger/Logger.php index ea6792b..fb55b6f 100644 --- a/Logger/Logger.php +++ b/Logger/Logger.php @@ -87,6 +87,6 @@ public function addRecord(int $level, string $message, array $context = [], Date print_r($message."\n"); } - return parent::addRecord($level, $message, $context); + return parent::addRecord($level, $message, $context, $datetime); } } diff --git a/Model/XMLWriter.php b/Model/XMLWriter.php index 3c4140f..2ba9402 100644 --- a/Model/XMLWriter.php +++ b/Model/XMLWriter.php @@ -20,7 +20,7 @@ class XMLWriter extends \XMLWriter * @param null $content * @param bool $cdata * - * @return bool|void + * @return bool */ public function writeElement($name, $content = null, $cdata = false): bool { @@ -31,26 +31,25 @@ public function writeElement($name, $content = null, $cdata = false): bool $this->endElement(); return true; } else { - parent::writeElement($name, $content); - return true; + return parent::writeElement($name, $content); } + return false; } /** * @param null $content * @param bool $cdata * - * @return bool|void + * @return bool */ public function writeRaw($content = null, $cdata = false): bool { $content = trim((string)$content); if ($cdata) { - $this->writeCdata($content); - return true; + return $this->writeCdata($content); } else { - parent::writeRaw($content); - return true; + return parent::writeRaw($content); } + return false; } -} \ No newline at end of file +} diff --git a/ViewModel/Pixel.php b/ViewModel/Pixel.php index 29a0abf..bc61652 100644 --- a/ViewModel/Pixel.php +++ b/ViewModel/Pixel.php @@ -132,11 +132,11 @@ public function getOrderDetails() $this->orderDetails['tax'] = number_format((float)$order->getTaxAmount() ?? 0.0, 2, '.', ''); $this->orderDetails['shipping'] = number_format((float)$order->getShippingAmount() ?? 0.0, 2, '.', ''); if (!$this->taxConfig->discountTax()) { - $this->orderDetails['discount'] = number_format(abs((float)$order->getDiscountAmount()) ?? 0.0, 2, '.', ''); + $this->orderDetails['discount'] = number_format((float)abs((float)$order->getDiscountAmount()) ?? 0.0, 2, '.', ''); } else { //when discount is applied to products "including tax" - extract tax compensation amount from "discount".   $this->orderDetails['discount'] = number_format( - abs((float)$order->getDiscountAmount()) - abs((float)$order->getDiscountTaxCompensationAmount()) ?? 0.0, 2, '.', '' ); + (float)abs((float)$order->getDiscountAmount()) - (float)abs((float)$order->getDiscountTaxCompensationAmount()) ?? 0.0, 2, '.', '' ); } if ($address) { From 3482bdb48b7d2597bdfaaa393d4d991f9989dc40 Mon Sep 17 00:00:00 2001 From: Ian Anderson Date: Wed, 23 Aug 2023 10:39:01 -0400 Subject: [PATCH 2/6] indexer, and undefined http user agent fixes --- Model/BVSEOSDK/BVFooter.php | 6 ++++-- Model/BVSEOSDK/Base.php | 7 ++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Model/BVSEOSDK/BVFooter.php b/Model/BVSEOSDK/BVFooter.php index 5f9d773..84ba94f 100644 --- a/Model/BVSEOSDK/BVFooter.php +++ b/Model/BVSEOSDK/BVFooter.php @@ -132,13 +132,15 @@ public function buildSDKDebugFooter() $footer .= "\n".'
  • '.$this->base->config['bv_root_folder'].'
  • '; $footer .= "\n".'
  • '.$this->base->config['charset'].'
  • '; $footer .= "\n".'
  • '.$ssl_enabled.'
  • '; - $footer .= "\n".'
  • '.$this->base->config['crawler_agent_pattern'].'
  • '; + $userAgent = $_SERVER['HTTP_USER_AGENT'] ?? ''; + $crawlerAgentPattern = $this->base->config['crawler_agent_pattern'] ?? ''; + $footer .= "\n".'
  • '.$crawlerAgentPattern.'
  • '; $footer .= "\n".'
  • '.urlencode($subject_id).'
  • '; $footer .= "\n".'
  • '.$sdk_enabled.'
  • '; $footer .= "\n".'
  • bvseo-'.$this->base->config['page'].'
  • '; - $footer .= "\n".'
  • '.$_SERVER['HTTP_USER_AGENT'].'
  • '; + $footer .= "\n".'
  • '.$userAgent.'
  • '; $footer .= "\n".'
  • '.$this->base->config['page_url'].'
  • '; $footer .= "\n".'
  • '.$this->base->config['base_url'].'
  • '; $footer .= "\n".'
  • '.$content_type.'
  • '; diff --git a/Model/BVSEOSDK/Base.php b/Model/BVSEOSDK/Base.php index 4219a17..c60a3a7 100644 --- a/Model/BVSEOSDK/Base.php +++ b/Model/BVSEOSDK/Base.php @@ -45,7 +45,8 @@ public function __construct($params = array()) : $this->config['execution_timeout']; // set up combined user agent to be passed to cloud storage (if needed) - $this->config['user_agent'] = "bv_php_sdk/3.2.1;".$_SERVER['HTTP_USER_AGENT']; + $userAgent = $_SERVER['HTTP_USER_AGENT'] ?? ''; + $this->config['user_agent'] = "bv_php_sdk/3.2.1;".$userAgent; } protected function validateParams($params) @@ -287,6 +288,10 @@ private function _isBot() return true; } + if (!isset($this->config['crawler_agent_pattern']) || !isset($_SERVER['HTTP_USER_AGENT'])) { + return true; + } + // search the user agent string for an indication if this is a search bot or not return mb_eregi('('.$this->config['crawler_agent_pattern'].')', $_SERVER['HTTP_USER_AGENT']); } From ae1d9a89ec5252bd4c4eb6daa7b094e221a94dda Mon Sep 17 00:00:00 2001 From: Ian Anderson Date: Thu, 24 Aug 2023 09:58:10 -0400 Subject: [PATCH 3/6] Coding Style changes --- .../Adminhtml/Config/Sftp/TestConnection.php | 11 +++++--- Model/BVSEOSDK/BV.php | 26 ++++++++++++++++++- Model/BVSEOSDK/Base.php | 15 +++++++++++ Model/BVSEOSDK/Questions.php | 4 +++ Model/BVSEOSDK/Reviews.php | 4 +++ Model/BVSEOSDK/SellerRatings.php | 4 +++ Model/BVSEOSDK/Spotlights.php | 4 +++ Model/BVSEOSDK/Stories.php | 4 +++ Model/Indexer/Eav.php | 7 +++++ Setup/Patch/Data/UpgradeBvDataAtttribute.php | 1 + 10 files changed, 76 insertions(+), 4 deletions(-) diff --git a/Controller/Adminhtml/Config/Sftp/TestConnection.php b/Controller/Adminhtml/Config/Sftp/TestConnection.php index 79dc2bb..a7e121a 100644 --- a/Controller/Adminhtml/Config/Sftp/TestConnection.php +++ b/Controller/Adminhtml/Config/Sftp/TestConnection.php @@ -22,7 +22,12 @@ */ class TestConnection extends Action { - + public $sftp; + public $storeManager; + public $configProvider; + public $resultJsonFactory; + public $tagFilter; + /** * TestConnection constructor. * @@ -88,10 +93,10 @@ public function execute() /** - * @var \Magento\Framework\Controller\Result\Json $resultJson + * @var \Magento\Framework\Controller\Result\Json $resultJson */ $resultJson = $this->resultJsonFactory->create(); return $resultJson->setData($result); } -} \ No newline at end of file +} diff --git a/Model/BVSEOSDK/BV.php b/Model/BVSEOSDK/BV.php index 6a3c900..a732d32 100644 --- a/Model/BVSEOSDK/BV.php +++ b/Model/BVSEOSDK/BV.php @@ -54,6 +54,31 @@ */ class BV { + public $config; + /** + * @var \Bazaarvoice\Connector\Model\BVSEOSDK\Reviews + */ + public $reviews; + /** + * @var \Bazaarvoice\Connector\Model\BVSEOSDK\Questions + */ + public $questions; + /** + * @var \Bazaarvoice\Connector\Model\BVSEOSDK\Stories + */ + public $stories; + /** + * @var \Bazaarvoice\Connector\Model\BVSEOSDK\Spotlights + */ + public $spotlights; + /** + * @var \Bazaarvoice\Connector\Model\BVSEOSDK\SellerRatings + */ + public $sellerratings; + /** + * @var \Bazaarvoice\Connector\Model\BVSEOSDK\SellerRatings|\Bazaarvoice\Connector\Model\BVSEOSDK\Reviews|\Bazaarvoice\Connector\Model\BVSEOSDK\Questions|\Bazaarvoice\Connector\Model\BVSEOSDK\Stories|\Bazaarvoice\Connector\Model\BVSEOSDK\Spotlights + */ + public $SEO; /** * BV Class Constructor @@ -196,4 +221,3 @@ protected function validateParameters($params) } } } - diff --git a/Model/BVSEOSDK/Base.php b/Model/BVSEOSDK/Base.php index c60a3a7..5fce194 100644 --- a/Model/BVSEOSDK/Base.php +++ b/Model/BVSEOSDK/Base.php @@ -18,6 +18,21 @@ */ class Base { + + public $config; + /** + * @var array|array + */ + public $bv_config; + public $seo_url; + /** + * @var float|string + */ + public $start_time; + /** + * @var float + */ + public $response_time; private $msg = ''; public function __construct($params = array()) diff --git a/Model/BVSEOSDK/Questions.php b/Model/BVSEOSDK/Questions.php index 31cd36c..8179f5e 100644 --- a/Model/BVSEOSDK/Questions.php +++ b/Model/BVSEOSDK/Questions.php @@ -15,6 +15,10 @@ */ class Questions extends Base { + /** + * @var array|array + */ + public $confi function __construct($params = array()) { diff --git a/Model/BVSEOSDK/Reviews.php b/Model/BVSEOSDK/Reviews.php index 37c01f2..7d242ff 100644 --- a/Model/BVSEOSDK/Reviews.php +++ b/Model/BVSEOSDK/Reviews.php @@ -15,6 +15,10 @@ */ class Reviews extends Base { + /** + * @var array|array + */ + public $config; function __construct($params = array()) { diff --git a/Model/BVSEOSDK/SellerRatings.php b/Model/BVSEOSDK/SellerRatings.php index ae01e30..87c8fce 100644 --- a/Model/BVSEOSDK/SellerRatings.php +++ b/Model/BVSEOSDK/SellerRatings.php @@ -10,6 +10,10 @@ class SellerRatings extends Base { + /** + * @var array + */ + public $config; function __construct($params = array()) { diff --git a/Model/BVSEOSDK/Spotlights.php b/Model/BVSEOSDK/Spotlights.php index 1900051..b37fa1d 100644 --- a/Model/BVSEOSDK/Spotlights.php +++ b/Model/BVSEOSDK/Spotlights.php @@ -10,6 +10,10 @@ class Spotlights extends Base { + /** + * @var array + */ + public $config; function __construct($params = array()) { diff --git a/Model/BVSEOSDK/Stories.php b/Model/BVSEOSDK/Stories.php index c14613f..1e37c1f 100644 --- a/Model/BVSEOSDK/Stories.php +++ b/Model/BVSEOSDK/Stories.php @@ -15,6 +15,10 @@ */ class Stories extends Base { + /** + * @var array|array + */ + public $config; function __construct($params = array()) { diff --git a/Model/Indexer/Eav.php b/Model/Indexer/Eav.php index 1048634..d6b4864 100644 --- a/Model/Indexer/Eav.php +++ b/Model/Indexer/Eav.php @@ -46,6 +46,13 @@ class Eav implements IndexerActionInterface, MviewActionInterface { + /** + * @var \Magento\Catalog\Helper\Image + */ + public $imageHelper; + public $assetRepository; + public $design; + public $theme; /** * @var \Bazaarvoice\Connector\Logger\Logger */ diff --git a/Setup/Patch/Data/UpgradeBvDataAtttribute.php b/Setup/Patch/Data/UpgradeBvDataAtttribute.php index c228b51..ab1c6fa 100644 --- a/Setup/Patch/Data/UpgradeBvDataAtttribute.php +++ b/Setup/Patch/Data/UpgradeBvDataAtttribute.php @@ -30,6 +30,7 @@ class UpgradeBvDataAtttribute implements DataPatchInterface, PatchRevertableInterface { + public $salesSetupFactory; const MODULE_NAME = 'Bazaarvoice_Connector'; /** * @var ModuleDataSetupInterface From f7890bcec550a1052f904ebb190ead6bee3dcd5b Mon Sep 17 00:00:00 2001 From: Ian Anderson Date: Thu, 24 Aug 2023 10:05:35 -0400 Subject: [PATCH 4/6] syntax error fix --- Model/BVSEOSDK/Questions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Model/BVSEOSDK/Questions.php b/Model/BVSEOSDK/Questions.php index 8179f5e..6041f31 100644 --- a/Model/BVSEOSDK/Questions.php +++ b/Model/BVSEOSDK/Questions.php @@ -18,7 +18,7 @@ class Questions extends Base /** * @var array|array */ - public $confi + public $config; function __construct($params = array()) { From 0dfc24c4ee22902788ad51436b6e1e5408fba1ba Mon Sep 17 00:00:00 2001 From: Ian Anderson Date: Fri, 22 Mar 2024 09:35:35 -0400 Subject: [PATCH 5/6] Update composer.json --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 8eee097..93c7a19 100644 --- a/composer.json +++ b/composer.json @@ -15,6 +15,7 @@ } }, "require": { - "php": "~7.0||~8.1.0||~8.2.0" ,"magento/framework": "~100.1|~101.0|~102.0|~103.0|~104.0" + "php": "~7.0||~8.1.0||~8.2.0||~8.3.0" , + "magento/framework": "~100.1|~101.0|~102.0|~103.0|~104.0" } } From ff5a66cf423c4f3f2f5d41a31f0581e61dde1a6c Mon Sep 17 00:00:00 2001 From: Ian Anderson Date: Fri, 22 Mar 2024 09:36:43 -0400 Subject: [PATCH 6/6] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 93c7a19..dcdd6b2 100644 --- a/composer.json +++ b/composer.json @@ -16,6 +16,6 @@ }, "require": { "php": "~7.0||~8.1.0||~8.2.0||~8.3.0" , - "magento/framework": "~100.1|~101.0|~102.0|~103.0|~104.0" + "magento/framework": "*" } }