Skip to content

Commit

Permalink
Merge pull request #264 from YotpoLtd/3.1.3-release
Browse files Browse the repository at this point in the history
3.1.3 release
  • Loading branch information
lgreenboim authored Feb 8, 2021
2 parents 194408e + fa4925e commit 8e16746
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 150 deletions.
7 changes: 7 additions & 0 deletions Block/Conversion.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,11 @@ public function getNoscriptSrc()
)
);
}

/**
* @return string
*/
public function getYotpoWidgetUrl() {
return $this->yotpoConfig->getYotpoWidgetUrl();
}
}
5 changes: 4 additions & 1 deletion Model/Jobs/OrdersSync.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,9 @@ public function execute()
$ordersCollection = $this->setOrderCollectionLimit($ordersCollection);

$orders = $this->yotpoSchema->prepareOrdersData($ordersCollection);
$ordersCollectionCount = $ordersCollection->count();
$ordersCount = count($orders);
$this->_processOutput("OrdersSync::execute() - Found {$ordersCount} orders for sync.", "debug");
$this->_processOutput("OrdersSync::execute() - Found {$ordersCount} orders for sync (" . ($ordersCollectionCount - $ordersCount) . " skipped).", "debug");
if ($ordersCount > 0) {
$resData = $this->yotpoApi->massCreate($orders, $storeId);
$status = (int) ((is_object($resData['body']) && property_exists($resData['body'], "code")) ? $resData['body']->code : $resData['status']);
Expand All @@ -195,6 +196,8 @@ public function execute()
$this->_processOutput("OrdersSync::execute() - Orders sync for store ID: {$storeId} [SUCCESS]", "debug");
}
}
} elseif ($ordersCollectionCount) {
$this->flagItems('orders', $storeId, $this->getCollectionIds($ordersCollection));
}
} catch (\Exception $e) {
$this->_processOutput("OrdersSync::execute() - Exception: Failed sync orders for store ID: {$storeId} - " . $e->getMessage() . "\n" . $e->getTraceAsString(), "error");
Expand Down
113 changes: 0 additions & 113 deletions Setup/InstallSchema.php

This file was deleted.

55 changes: 49 additions & 6 deletions Setup/UpgradeSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,13 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con
$this->appConfig->reinit();
}

$defaultConnection = $installer->getConnection();
$salesConnection = $installer->getConnection('sales');
$yotpoSyncFullTableName = $installer->getTable('yotpo_sync');
$yotpoOrderStatusHistoryFullTableName = $installer->getTable('yotpo_order_status_history');
$yotpoRichSnippetsTable = $installer->getTable('yotpo_rich_snippets');

if (!$salesConnection->isTableExists($yotpoSyncFullTableName)) {
$defaultConnection = $installer->getConnection();
$withDataMigration = $defaultConnection->isTableExists($yotpoSyncFullTableName);

$syncTable = $salesConnection->newTable(
Expand Down Expand Up @@ -160,7 +161,6 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con
}

if (!$salesConnection->isTableExists($yotpoOrderStatusHistoryFullTableName)) {
$defaultConnection = $installer->getConnection();
$withDataMigration = $defaultConnection->isTableExists($yotpoOrderStatusHistoryFullTableName);

$yotpoOrderStatusHistoryTable = $salesConnection->newTable(
Expand Down Expand Up @@ -220,10 +220,53 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con
}
}

$richSnippetsTable = $installer->getConnection()->describeTable($installer->getTable('yotpo_rich_snippets'));
if (!$defaultConnection->isTableExists($yotpoRichSnippetsTable)) {
$richSnippetsTable = $defaultConnection->newTable(
$yotpoRichSnippetsTable
)->addColumn(
'rich_snippet_id',
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
null,
['identity' => true, 'nullable' => false, 'primary' => true],
'Id'
)->addColumn(
'product_id',
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
null,
['nullable' => false],
'Product Id'
)->addColumn(
'store_id',
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
null,
['nullable' => false],
'Store Id'
)->addColumn(
'average_score',
\Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL,
'10,2',
['nullable' => false],
'Average Score'
)->addColumn(
'reviews_count',
\Magento\Framework\DB\Ddl\Table::TYPE_FLOAT,
null,
['nullable' => false],
'Reviews Count'
)->addColumn(
'expiration_time',
\Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP,
null,
['nullable' => false],
'Expiry Time'
);
$defaultConnection->createTable($richSnippetsTable);
}

$richSnippetsTable = $defaultConnection->describeTable($yotpoRichSnippetsTable);
if (isset($richSnippetsTable['average_score']) && $richSnippetsTable['average_score']['DATA_TYPE'] !== \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL) {
$installer->getConnection()->changeColumn(
$installer->getTable('yotpo_rich_snippets'),
$defaultConnection->changeColumn(
$yotpoRichSnippetsTable,
'average_score',
'average_score',
[
Expand All @@ -232,7 +275,7 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con
'comment' => 'Average Score'
]
);
$installer->getConnection()->truncateTable($installer->getTable('yotpo_rich_snippets'));
$defaultConnection->truncateTable($yotpoRichSnippetsTable);
}

$installer->endSetup();
Expand Down
44 changes: 14 additions & 30 deletions etc/csp_whitelist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,56 +3,40 @@
<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>
<value id="yotpo_main" type="host">*.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>
<value id="yotpo_main" type="host">*.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>
<value id="yotpo_main" type="host">*.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>
<value id="yotpo_main" type="host">*.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>
<value id="yotpo_main" type="host">*.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>
<value id="yotpo_main" type="host">*.yotpo.com</value>
<value id="googleapis_main" type="host">*.googleapis.com</value>
</values>
</policy>
<policy id="font-src">
<values>
<value id="yotpo_main" type="host">*.yotpo.com</value>
<value id="googleapis_main" type="host">*.googleapis.com</value>
<value id="gstatic_main" type="host">*.gstatic.com</value>
</values>
</policy>
</policies>
Expand Down

0 comments on commit 8e16746

Please sign in to comment.