Vendor Catalog Batch¶
Batch Type Key: vendor_catalog
Purpose: Allows updating product costs from new catalog data
Default Handler: VendorCatalogHandler
Data for this type of batch usually comes from a spreadsheet or similar file, as obtained directly from the vendor. You can also define a “common” format to use, in which case you would convert each vendor file to that format. (That is to cut down on the number of file parsers needed.)
In any case executing this batch will just update Rattail by default; you may want a custom handler to update your POS system instead.
Adding a New Vendor Catalog File Parser¶
Let’s say you buy product from a vendor named “Acme Distribution” and you want to add support for their catalog file format.
First you must define the file parser class, and register it.
We suggest keeping catalog parsers in a particular folder, e.g.
~/src/poser/poser/vendor/catalogs/
in your project. Create
folders as needed and then within that create a new file acme.py
and for now just put this in it:
from rattail.vendors.catalogs import CatalogParser
class AcmeCatalogParser(CatalogParser):
key = 'poser.acme'
vendor_key = 'poser.acme'
Now you must register it. To do this, first add something like the
following to setup.py
for your project:
setup(
# ...
entry_points = {
'rattail.vendors.catalogs.parsers': [
'poser.acme = poser.vendors.catalogs.acme:AcmeCatalogParser',
],
},
)
Then re-install your project, e.g. with:
cd /srv/envs/poser
bin/pip install -e ~/src/poser
At this point your parser should be visible within the web app and you can move on to fleshing out the parser logic, and test it by making a new batch in the web app etc.
See rattail.vendors.catalogs.CatalogParser
for
details of what attributes and methods you can implement.
See https://kallithea.rattailproject.org/rattail-project/rattail/files/master/rattail/contrib/vendors/catalogs/ for some example parsers.