Skip to content

Commit 444a6bf

Browse files
committed
WZ-4212: Added more details in Wizzy section on Product Details Page - When a Product is Skipped
1 parent 43b16f3 commit 444a6bf

File tree

4 files changed

+71
-28
lines changed

4 files changed

+71
-28
lines changed

Block/Adminhtml/Sync/Status.php

+24-11
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,26 @@
88
use Magento\Store\Model\StoreManagerInterface;
99
use Wizzy\Search\Services\Store\StoreManager;
1010
use Magento\Framework\View\Element\Template;
11+
use Wizzy\Search\Services\Model\SyncSkippedEntities;
1112

1213
class Status extends Template
1314
{
1415
protected $_template = 'sync/status.phtml';
16+
public $syncSkippedEntities;
1517
public function __construct(
1618
EntitiesSync $entitiesSync,
1719
Context $context,
1820
Registry $registry,
1921
StoreManagerInterface $storeManager,
2022
StoreManager $_storemanager,
23+
SyncSkippedEntities $syncSkippedEntities,
2124
array $data = []
2225
) {
2326
$this->entitiesSync = $entitiesSync;
2427
$this->registry = $registry;
2528
$this->storeManager = $storeManager;
2629
$this->_storemanager = $_storemanager;
30+
$this->syncSkippedEntities = $syncSkippedEntities;
2731
parent::__construct($context, $data);
2832
}
2933

@@ -32,22 +36,31 @@ public function getSyncStatus()
3236
$entityId = $this->registry->registry('current_product')->getId();
3337
$storeId = $this->storeManager->getStore()->getId();
3438
$storeIds = $this->_storemanager->getToSyncStoreIds($storeId);
35-
$syncResults = [];
36-
39+
$entitiesSyncStatus_ = [];
3740
foreach ($storeIds as $storeId) {
38-
$entityStatus = $this->entitiesSync->getEntitiesSyncStatus($entityId, $storeId, 'product');
39-
if (count($entityStatus) == 0) {
40-
$entityStatus = [
41-
[
41+
$entitiesSyncStatus = $this->entitiesSync->getEntitiesSyncStatus($entityId, $storeId, 'product');
42+
$skippedEntitiesData = $this->syncSkippedEntities->getSkippedEntityById($storeId, $entityId, 'product');
43+
44+
if ($entitiesSyncStatus) {
45+
foreach ($entitiesSyncStatus as $entitySyncStatus) {
46+
$entitiesSyncStatus_[] = [
47+
"store_id" => $entitySyncStatus['store_id'],
48+
"status" => $entitySyncStatus['status'],
49+
"updated_at" => $entitySyncStatus['updated_at'],
50+
"skipped_data" => ($skippedEntitiesData && !empty($skippedEntitiesData))
51+
? $skippedEntitiesData
52+
: null,
53+
];
54+
}
55+
} else {
56+
$entitiesSyncStatus_[] = [
4257
"store_id" => $storeId,
4358
"status" => -1,
44-
"updated_at" => " -"
45-
]
59+
"updated_at" => "-"
4660
];
4761
}
48-
$syncResults[] = $entityStatus;
49-
}
5062

51-
return $syncResults;
63+
}
64+
return [$entitiesSyncStatus_];
5265
}
5366
}

Helpers/API/WizzyAPIEndPoints.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
class WizzyAPIEndPoints
66
{
7-
const BASE_END_POINT = "https://api.wizsearch.in/v1";
7+
const BASE_END_POINT = "https://testing.api.wizzy.ai/v1";
88
const STORES_BASE_AUTH = self::BASE_END_POINT.'/stores';
99
const PRODUCTS_BASE_AUTH = self::BASE_END_POINT.'/products';
1010
const CURRENCIES_BASE_AUTH = self::BASE_END_POINT.'/currencies';

Services/Model/SyncSkippedEntities.php

+22-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Wizzy\Search\Helpers\DB\WizzyTables;
66
use Wizzy\Search\Model\SyncSkippedEntitiesFactory;
77
use Wizzy\Search\Services\DB\ConnectionManager;
8+
use Wizzy\Search\Model\ResourceModel\SyncSkippedEntities\CollectionFactory;
89

910
class SyncSkippedEntities
1011
{
@@ -13,13 +14,16 @@ class SyncSkippedEntities
1314

1415
private $syncSkippedEntitiesFactory;
1516
private $connectionManager;
17+
public $syncSkippedEntitiesCollectionFactory;
1618

1719
public function __construct(
1820
SyncSkippedEntitiesFactory $syncSkippedEntitiesFactory,
19-
ConnectionManager $connectionManager
21+
ConnectionManager $connectionManager,
22+
CollectionFactory $syncSkippedEntitiesCollectionFactory
2023
) {
2124
$this->syncSkippedEntitiesFactory = $syncSkippedEntitiesFactory;
2225
$this->connectionManager = $connectionManager;
26+
$this->syncSkippedEntitiesCollectionFactory = $syncSkippedEntitiesCollectionFactory;
2327
}
2428

2529
public function addSkippedEntities($skippedEntities, $storeId, $entityType = self::ENTITY_TYPE_PRODUCT)
@@ -57,4 +61,21 @@ public function deleteSkippedEntities($entityIds, $storeId, $entityType = self::
5761

5862
return $entities;
5963
}
64+
public function getSkippedEntityById($storeId, $entityId, $entityType = null)
65+
{
66+
$collection = $this->syncSkippedEntitiesCollectionFactory->create();
67+
$collection->addFieldToFilter('store_id', $storeId);
68+
$collection->addFieldToFilter('entity_id', $entityId);
69+
70+
if ($entityType !== null) {
71+
$collection->addFieldToFilter('entity_type', $entityType);
72+
}
73+
74+
$skippedEntities = null;
75+
foreach ($collection->getItems() as $item) {
76+
$skippedEntities = $item->getData('entity_data');
77+
}
78+
79+
return $skippedEntities;
80+
}
6081
}

view/adminhtml/templates/sync/status.phtml

+24-15
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,33 @@
22
/** @var $block \Magento\Framework\View\Element\Template */
33
$syncResults = $block->getSyncStatus();
44
foreach ($syncResults as $syncResult) {
5-
foreach ($syncResult as $sync) { ?>
5+
foreach ($syncResult as $sync) {
6+
?>
67
<div class="admin__fieldset-wrapper-title">
7-
<p class="product-id"> <?= "<b>Store ID</b> : ",$sync['store_id'];?></p>
8-
<span><?= $block->escapeHtmlAttr(('Sync Status :'));?></span>
9-
<?php if ($sync['status'] == 1) {
10-
?> <b><?= $block->escapeHtmlAttr(('Synced'));?></b> <?php
11-
} elseif ($sync['status'] == 0) {
12-
?> <b><?= $block->escapeHtmlAttr(('In sync'));?></b> <?php
13-
} elseif ($sync['status'] == -1) {
14-
?> <b><?= $block->escapeHtmlAttr(('No entities to be synced !'));?></b> <?php
15-
}
16-
?>
8+
<p class="product-id"><?= "<b>Store ID</b> : ", $block->escapeHtml($sync['store_id']); ?></p>
9+
<span><?= $block->escapeHtml('Sync Status :'); ?></span>
10+
<?php
11+
if ($sync['status'] == 1 && !$sync['skipped_data']) { ?>
12+
<b><?= $block->escapeHtml('Synced'); ?></b>
13+
<?php
14+
} elseif ($sync['status'] == 0) { ?>
15+
<b><?= $block->escapeHtml('In sync'); ?></b>
16+
<?php
17+
} elseif ($sync['status'] == -1) { ?>
18+
<b><?= $block->escapeHtml('Product is not added in sync yet'); ?></b>
19+
<?php
20+
} elseif ($sync['skipped_data']) { ?>
21+
<b><?= $block->escapeHtml('Product Skipped during Sync'); ?></b>
22+
<div class="admin__fieldset-note admin__scope-old"></div>
23+
<span><?= $block->escapeHtml('Reason: '); ?></span>
24+
<b><?= $block->escapeHtml($sync['skipped_data']); ?></b>
25+
<?php } ?>
1726
</div>
1827
<div class="admin__fieldset-wrapper-title">
19-
<span><?= $block->escapeHtmlAttr(('Last Updated At :'));?></span>
20-
<b> <?= "", $sync['updated_at']; ?></b>
21-
</div> </br>
28+
<span><?= $block->escapeHtml('Last Updated At :'); ?></span>
29+
<b><?= $block->escapeHtml($sync['updated_at']); ?></b>
30+
</div>
31+
<br>
2232
<?php }
2333
}
24-
2534
?>

0 commit comments

Comments
 (0)