Tweak how product lookup happens for vendor catalog batch
this still isn't perfect but i think it's an improvement..
This commit is contained in:
parent
8e66a64848
commit
164f491363
|
@ -35,14 +35,21 @@ class VendorCatalogHandler(base.VendorCatalogHandler):
|
||||||
self.core_products_by_upc = self.cache_model(self.core_session,
|
self.core_products_by_upc = self.cache_model(self.core_session,
|
||||||
corepos.Product,
|
corepos.Product,
|
||||||
key='upc',
|
key='upc',
|
||||||
query=query)
|
query=query,
|
||||||
|
progress=progress)
|
||||||
|
|
||||||
query = self.core_session.query(corepos.VendorItem)\
|
query = self.core_session.query(corepos.VendorItem)\
|
||||||
.filter(corepos.VendorItem.vendor_id == int(batch.vendor_id))
|
.filter(corepos.VendorItem.vendor_id == int(batch.vendor_id))
|
||||||
self.core_vendor_items_by_sku = self.cache_model(self.core_session,
|
self.core_vendor_items_by_sku = self.cache_model(self.core_session,
|
||||||
corepos.VendorItem,
|
corepos.VendorItem,
|
||||||
key='sku',
|
key='sku',
|
||||||
query=query)
|
query=query,
|
||||||
|
progress=progress)
|
||||||
|
self.core_vendor_items_by_upc = self.cache_model(self.core_session,
|
||||||
|
corepos.VendorItem,
|
||||||
|
key='upc',
|
||||||
|
query=query,
|
||||||
|
progress=progress)
|
||||||
|
|
||||||
setup_populate = setup_common
|
setup_populate = setup_common
|
||||||
setup_refresh = setup_common
|
setup_refresh = setup_common
|
||||||
|
@ -73,7 +80,10 @@ class VendorCatalogHandler(base.VendorCatalogHandler):
|
||||||
core_product = self.core_products_by_upc.get(row.item_id)
|
core_product = self.core_products_by_upc.get(row.item_id)
|
||||||
|
|
||||||
# find the CORE `vendorItems` record, matching by `vendorItems.sku`
|
# find the CORE `vendorItems` record, matching by `vendorItems.sku`
|
||||||
|
# preferably, but falling back to match on `vendorItems.upc`
|
||||||
core_vendor_item = self.core_vendor_items_by_sku.get(row.vendor_code)
|
core_vendor_item = self.core_vendor_items_by_sku.get(row.vendor_code)
|
||||||
|
if not core_vendor_item:
|
||||||
|
core_vendor_item = self.core_vendor_items_by_upc.get(row.item_id)
|
||||||
|
|
||||||
# if the catalog UPC is not found in `products` but the SKU *is* found
|
# if the catalog UPC is not found in `products` but the SKU *is* found
|
||||||
# in `vendorItems` *and* the latter ties back to valid `products`
|
# in `vendorItems` *and* the latter ties back to valid `products`
|
||||||
|
|
Loading…
Reference in a new issue