Skip to content

Instantly share code, notes, and snippets.

@SysPete
Last active August 29, 2015 14:09
Show Gist options
  • Save SysPete/4cf8f3b172269a698482 to your computer and use it in GitHub Desktop.
Save SysPete/4cf8f3b172269a698482 to your computer and use it in GitHub Desktop.
SELECT product.sku, product.name, product.short_description, product.description, product.price
, product.uri, product.weight, product.priority, product.gtin, product.canonical_sku
, product.active, product.inventory_exempt, product.created, product.last_modified
, price_modifier.selling_price
FROM navigation_products me
JOIN products product
ON product.sku = me.sku
LEFT JOIN ( SELECT me.sku, MIN (me.price) AS selling_price
FROM price_modifiers me
LEFT JOIN roles role ON role.roles_id = me.roles_id
WHERE ( me.end_date IS NULL OR me.end_date >= '?' )
AND me.quantity = ?
AND ( me.start_date IS NULL OR me.start_date <= ? )
AND role.name IN ( ? )
GROUP BY me.sku ) price_modifier
ON product.sku = price_modifier.sku
WHERE product.active = ?
AND me.navigation_id = ?;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment