Smartlink ASI Promo Products Integration for WooCommerce
An import and sync engine that pulls the ASI SmartLink promo-products catalog into WooCommerce: products, variations, inventory and every media image, re-synced on a schedule without creating duplicates.
- Client
- Promotional-products reseller on WooCommerce
- My role
- WordPress / WooCommerce integration developer
- WooCommerce
- REST API
- PHP
- WP-CLI
- Action Scheduler
- System cron
- unique key for every upsert
- SKU
- sync, only changed rows are touched
- Delta
- duplicate products on re-run, by design
- 0
- catalog and inventory sync
- Scheduled
unique key for every upsert
sync, only changed rows are touched
duplicate products on re-run, by design
catalog and inventory sync
The challenge
The client sells promotional products from the ASI SmartLink catalog and needed that catalog inside WooCommerce: products, variations, stock levels and all images. Doing it by hand was not realistic at catalog size.
ASI-style feeds arrive as flat rows, one per SKU, with colour, size and option columns. Each synced product also needed the supplier's base cost plus a configurable commission, and the whole catalog had to stay current without anyone re-importing it.
What I built
- 01
Flat feed to variable products
The importer groups rows by parent SKU, creates the parent variable product once, then creates attributes and variations (colours, sizes, decoration options). Existing variations are updated in place, not deleted and recreated, so variation IDs and any external references survive.
- 02
Commission as a pricing pipeline
Price runs through base cost, supplier tier, category markup, a minimum margin floor, rounding (to .99 or 0.05), then currency and tax. Order matters: a flat multiplier breaks on tiered pricing and on products where the margin floor should win over the percentage.
- 03
Idempotent upsert by SKU
SKU is the unique key, never the title or post ID. Re-running the import updates existing products and never creates a second copy.
- 04
Delta sync instead of full sync
Each row is hashed (price, stock, image set) and the hash is stored. Only products whose hash changed are touched, so a nightly run does not rewrite the whole catalog or risk timeouts.
- 05
Image handling at volume
Catalogs have many images per product, often with the same URL across SKUs. Images are de-duplicated by URL hash, sideloaded once, and the attachment ID is reused, which keeps the media library small and the import fast.
- 06
Explicit deleted-product policy
When a SKU disappears from the feed, the importer trashes it, sets it to draft, or marks it out of stock, as configured. Silent deletion would break order history and inbound links.
- 07
Server cron and run reports
WP-Cron is disabled in favour of a system cron that runs a WP-CLI command. Each run logs rows read, created, updated, skipped and failed, with a per-row error table, so a bad run is visible instead of silent.
Gotchas and how I fixed them
Attributes must be global for filters to work
Variation attribute values need to be created as global (taxonomy) attributes. Local attributes do not appear in WooCommerce filter widgets.
Large imports exhaust memory in one request
Calling wp_insert_post and save() on a whole catalog in a single request runs out of memory. Batch through WP-CLI or Action Scheduler instead.
Round after the markup, not before
If rounding runs before the markup, the margin floor and the rounding rule fight each other and prices come out wrong. Rounding is applied last in the pipeline.
Results
- Catalog, variations, inventory and all media images load into WooCommerce automatically.
- Re-running the import updates products in place; the SKU key prevents duplicates.
- Only changed rows are processed on each scheduled run.
- Every product is priced through the same markup pipeline, so margins are applied consistently.
- Each run produces a log with created, updated, skipped and failed counts.
Questions people ask
Can ASI SmartLink products be imported into WooCommerce automatically?
Yes. The integration reads the SmartLink feed and creates WooCommerce products, variations, inventory and images, then re-syncs on a schedule so the catalog stays current.
How do you add a markup or commission to supplier prices in WooCommerce?
Prices go through a pipeline: base cost, supplier tier, category markup, a minimum margin floor, rounding, then currency and tax. A single flat multiplier does not handle tiers or margin floors, so the steps run in a fixed order.
How do you stop a WooCommerce import from creating duplicate products?
Use the SKU as the unique key for every upsert. The importer looks up the SKU and updates the existing product instead of creating a new one, so re-running it is safe.
What happens to products that disappear from the supplier feed?
You choose the policy up front: trash them, set them to draft, or mark them out of stock. Deleting silently is avoided because it breaks order history and inbound links.