Hide products on woocommerce when deleted
This commit is contained in:
parent
30ed06fcbf
commit
a577c3e032
|
@ -44,6 +44,12 @@ class Product(ShopWooCommerceIdMixin, metaclass=PoolMeta):
|
|||
parent = parent.parent
|
||||
return ''
|
||||
|
||||
def woocommerce_disable_data(self, shop):
|
||||
return {
|
||||
'status': 'private',
|
||||
'catalog_visibility': 'hidden',
|
||||
}
|
||||
|
||||
def get_woocommerce_entity(self):
|
||||
short_description = description = (self.description or '')
|
||||
lines = description.splitlines()
|
||||
|
|
11
web.py
11
web.py
|
@ -312,8 +312,15 @@ class Shop(metaclass=PoolMeta):
|
|||
products,
|
||||
'products')
|
||||
|
||||
# TODO: Manage removed
|
||||
# shop.products_removed = []
|
||||
logger.info("Removing products for %s", shop.rec_name)
|
||||
wcapi = shop.get_woocommerce_api()
|
||||
# Rebrowse to get proper context
|
||||
for removed in Product.browse(shop.products_removed):
|
||||
shop.woocommerce_response(
|
||||
wcapi.post('products/%d' % (removed.woocommerce_id),
|
||||
removed.woocommerce_disable_data(shop)))
|
||||
shop.products_removed = []
|
||||
# TODO: Manage category removal
|
||||
# shop.categories_removed = []
|
||||
logger.info("Finised syncronization for %s", shop.rec_name)
|
||||
|
||||
|
|
Loading…
Reference in New Issue