Skip to content

Commit

Permalink
Merge pull request #251 from YotpoLtd/3.1.1-release
Browse files Browse the repository at this point in the history
3.1.1 release
  • Loading branch information
DanGlz committed May 20, 2020
2 parents 7c8218d + bb83336 commit 1b6eb5b
Show file tree
Hide file tree
Showing 14 changed files with 155 additions and 67 deletions.
24 changes: 0 additions & 24 deletions Cron/OrdersSyncJob.php

This file was deleted.

24 changes: 0 additions & 24 deletions Cron/UpdateMetadata.php

This file was deleted.

12 changes: 11 additions & 1 deletion Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -79,6 +80,11 @@ class Config
*/
private $logger;

/**
* @var YotpoLogger
*/
private $yotpoLogger;

/**
* @method __construct
* @param StoreManagerInterface $storeManager
Expand All @@ -89,6 +95,7 @@ class Config
* @param ModuleListInterface $moduleList
* @param ProductMetadataInterface $productMetadata
* @param LoggerInterface $logger
* @param YotpoLogger $yotpoLogger
*/
public function __construct(
StoreManagerInterface $storeManager,
Expand All @@ -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;
Expand All @@ -108,6 +116,7 @@ public function __construct(
$this->moduleList = $moduleList;
$this->productMetadata = $productMetadata;
$this->logger = $logger;
$this->yotpoLogger = $yotpoLogger;
}

/**
Expand Down Expand Up @@ -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;
}
Expand Down
6 changes: 6 additions & 0 deletions Model/Logger.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
namespace Yotpo\Yotpo\Model;

class Logger extends \Monolog\Logger
{
}
19 changes: 19 additions & 0 deletions Model/Logger/YotpoHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
namespace Yotpo\Yotpo\Model\Logger;

use Monolog\Logger;

class YotpoHandler extends \Magento\Framework\Logger\Handler\Base
{
/**
* Logging level
* @var int
*/
protected $loggerType = Logger::DEBUG;

/**
* File name
* @var string
*/
protected $fileName = '/var/log/yotpo_yotpo.log';
}
13 changes: 10 additions & 3 deletions Model/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,22 +95,29 @@ 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(),
'upc' => $product->getUpc(),
'isbn' => $product->getIsbn(),
'mpn' => $product->getMpn(),
'brand' => $product->getBrand(),
'brand' => $product->getBrand() ? $product->getAttributeText('brand') : null,
]
),
];
Expand Down
16 changes: 15 additions & 1 deletion Plugin/AbstractYotpoReviewsSummary.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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)
Expand Down
15 changes: 6 additions & 9 deletions Plugin/Review/Block/Product/ReviewRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 '';
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
10 changes: 10 additions & 0 deletions etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,15 @@
<orders_sync_limit>50</orders_sync_limit>
</sync_settings>
</yotpo>
<csp>
<mode>
<storefront>
<report_only>1</report_only>
</storefront>
<admin>
<report_only>1</report_only>
</admin>
</mode>
</csp>
</default>
</config>
59 changes: 59 additions & 0 deletions etc/csp_whitelist.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0"?>
<csp_whitelist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Csp/etc/csp_whitelist.xsd">
<policies>
<policy id="script-src">
<values>
<value id="yotpo_main" type="host">yotpo.com</value>
<value id="yotpo_main_www" type="host">www.yotpo.com</value>
<value id="yotpo_p" type="host">p.yotpo.com</value>
<value id="yotpo_staticw2" type="host">staticw2.yotpo.com</value>
<value id="yotpo_w2" type="host">w2.yotpo.com</value>
</values>
</policy>
<policy id="connect-src">
<values>
<value id="yotpo_main" type="host">yotpo.com</value>
<value id="yotpo_main_www" type="host">www.yotpo.com</value>
<value id="yotpo_p" type="host">p.yotpo.com</value>
<value id="yotpo_staticw2" type="host">staticw2.yotpo.com</value>
<value id="yotpo_w2" type="host">w2.yotpo.com</value>
</values>
</policy>
<policy id="frame-src">
<values>
<value id="yotpo_main" type="host">yotpo.com</value>
<value id="yotpo_main_www" type="host">www.yotpo.com</value>
<value id="yotpo_p" type="host">p.yotpo.com</value>
<value id="yotpo_staticw2" type="host">staticw2.yotpo.com</value>
<value id="yotpo_w2" type="host">w2.yotpo.com</value>
</values>
</policy>
<policy id="form-action">
<values>
<value id="yotpo_main" type="host">yotpo.com</value>
<value id="yotpo_main_www" type="host">www.yotpo.com</value>
<value id="yotpo_p" type="host">p.yotpo.com</value>
<value id="yotpo_staticw2" type="host">staticw2.yotpo.com</value>
<value id="yotpo_w2" type="host">w2.yotpo.com</value>
</values>
</policy>
<policy id="img-src">
<values>
<value id="yotpo_main" type="host">yotpo.com</value>
<value id="yotpo_main_www" type="host">www.yotpo.com</value>
<value id="yotpo_p" type="host">p.yotpo.com</value>
<value id="yotpo_staticw2" type="host">staticw2.yotpo.com</value>
<value id="yotpo_w2" type="host">w2.yotpo.com</value>
</values>
</policy>
<policy id="style-src">
<values>
<value id="yotpo_main" type="host">yotpo.com</value>
<value id="yotpo_main_www" type="host">www.yotpo.com</value>
<value id="yotpo_p" type="host">p.yotpo.com</value>
<value id="yotpo_staticw2" type="host">staticw2.yotpo.com</value>
<value id="yotpo_w2" type="host">w2.yotpo.com</value>
</values>
</policy>
</policies>
</csp_whitelist>
16 changes: 15 additions & 1 deletion etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,18 @@
</argument>
</arguments>
</virtualType>
</config>

<type name="Yotpo\Yotpo\Model\Logger\YotpoHandler">
<arguments>
<argument name="filesystem" xsi:type="object">Magento\Framework\Filesystem\Driver\File</argument>
</arguments>
</type>
<type name="Yotpo\Yotpo\Model\Logger">
<arguments>
<argument name="name" xsi:type="string">yotpoLogger</argument>
<argument name="handlers" xsi:type="array">
<item name="system" xsi:type="object">Yotpo\Yotpo\Model\Logger\YotpoHandler</item>
</argument>
</arguments>
</type>
</config>
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Yotpo_Yotpo" setup_version="3.1.0">
<module name="Yotpo_Yotpo" setup_version="3.1.1">
<sequence>
<module name="Magento_Backend" />
<module name="Magento_Catalog" />
Expand Down
4 changes: 2 additions & 2 deletions view/frontend/web/css/source/_module.less
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down

0 comments on commit 1b6eb5b

Please sign in to comment.