diff --git a/ecommerce_integrations/shopify/page/shopify_import_products/shopify_import_products.js b/ecommerce_integrations/shopify/page/shopify_import_products/shopify_import_products.js
index f3d63f22..1cfb57b0 100644
--- a/ecommerce_integrations/shopify/page/shopify_import_products/shopify_import_products.js
+++ b/ecommerce_integrations/shopify/page/shopify_import_products/shopify_import_products.js
@@ -176,7 +176,9 @@ shopify.ProductImporter = class {
'Name': product.title,
'SKUs': product.variants && product.variants.map(a => `${a.sku}`).join(', '),
'Status': this.getProductSyncStatus(product.synced),
- 'Action': !product.synced ? `` : '-',
+ 'Action': !product.synced ?
+ `` :
+ ``,
}));
return shopifyProducts;
@@ -217,12 +219,39 @@ shopify.ProductImporter = class {
.find('.indicator-pill')
.replaceWith(this.getProductSyncStatus(true));
- _this.remove();
+ _this.replaceWith(``);
});
});
+ this.wrapper.on('click', '.btn-resync', e => {
+ const _this = $(e.currentTarget);
+
+ _this.prop('disabled', true).text('Syncing...');
+
+ const product = _this.attr('data-product');
+ this.resyncProduct(product)
+ .then(status => {
+
+ if (!status) {
+ frappe.throw(__('Error syncing product'));
+ return;
+ }
+
+ _this.parents('.dt-row')
+ .find('.indicator-pill')
+ .replaceWith(this.getProductSyncStatus(true));
+
+ _this.prop('disabled', false).text('Re-sync');
+
+ })
+ .catch(ex => {
+ _this.prop('disabled', false).text('Re-sync');
+ frappe.throw(__('Error syncing Product'));
+ });
+ });
+
// pagination
this.wrapper.on('click', '.btn-prev,.btn-next', e => this.switchPage(e));
@@ -245,6 +274,20 @@ shopify.ProductImporter = class {
}
+ async resyncProduct(product) {
+
+ const { message: status } = await frappe.call({
+ method: 'ecommerce_integrations.shopify.page.shopify_import_products.shopify_import_products.resync_product',
+ args: { product },
+ });
+
+ if (status)
+ this.fetchProductCount();
+
+ return status;
+
+ }
+
async switchPage({ currentTarget }) {
const _this = $(currentTarget);
diff --git a/ecommerce_integrations/shopify/page/shopify_import_products/shopify_import_products.py b/ecommerce_integrations/shopify/page/shopify_import_products/shopify_import_products.py
index 58b3e9d8..056ac3cd 100644
--- a/ecommerce_integrations/shopify/page/shopify_import_products/shopify_import_products.py
+++ b/ecommerce_integrations/shopify/page/shopify_import_products/shopify_import_products.py
@@ -90,6 +90,25 @@ def sync_product(product):
return False
+@frappe.whitelist()
+def resync_product(product):
+ return _resync_product(product)
+
+
+@temp_shopify_session
+def _resync_product(product):
+ try:
+ item = Product.find(product)
+
+ for variant in item.variants:
+ shopify_product = ShopifyProduct(product, variant_id=variant.id)
+ shopify_product.sync_product()
+
+ return True
+ except Exception:
+ return False
+
+
def is_synced(product):
return ecommerce_item.is_synced(MODULE_NAME, integration_item_code=product)