Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 2.31 KB | None | 0 0
  1. select
  2.                 so.order_id, so.suborder_id,
  3.                 pe.sku, prodname.value as productName,
  4.                 thumbnail.value as thumbnail,
  5.                 avg(if(sb.bundle_id is null, soi.price, (1-sb.saving) * soi.price)) as price,
  6.                 soi.list_price as originalPrice,
  7.                 sum(if(sb.bundle_id is null, soi.qty, sb.qty * soi.qty)) as qty,
  8.                 ifnull(so.cod_fee, 0) as codFee,
  9.                 ifnull(so.shipping_fee, 0) as shippingFee,
  10.                 ifnull(so.giftwrap_fee, 0) as wrappingFee,
  11.                 so.discount_amount as discountAmount,
  12.                 so.tryout_discount as fpoint,
  13.                 IF(o.is_coin = 1, so.discount_amount, 0) as fhsCoin,
  14.                 CONCAT(sab.street ,' ', sab.city,' ', IFNULL(sab.region, '') ,' ', sab.country_id) AS billingAddress,
  15.                 CONCAT(sab.lastname,' ', sab.firstname) as billingName, sab.telephone AS billingPhone,
  16.                 CONCAT(sa.street ,' ', sa.city ,' ', IFNULL(sa.region, '') ,' ', IFNULL(sa.postcode, ''), ' ', sa.country_id) AS shippingAddress,
  17.                 CONCAT(sa.lastname,' ', sa.firstname) as shippingName, sa.telephone AS shippingPhone,
  18.                 so.is_sameday as isSameday
  19.                 from fahasa_suborder so
  20.                 join fahasa_suborder_item soi on so.order_id = soi.order_id and so.suborder_id = soi.suborder_id
  21.                 left join fahasa_suborder_bundle sb on soi.bundle_id = sb.bundle_id and soi.suborder_id = sb.suborder_id and soi.bundle_type = sb.bundle_type        
  22.                 join fhs_catalog_product_entity pe on pe.entity_id = soi.product_id
  23.                 LEFT JOIN fhs_catalog_product_entity_varchar thumbnail ON pe.entity_id = thumbnail.entity_id AND thumbnail.attribute_id = 87
  24.                 LEFT JOIN fhs_catalog_product_entity_varchar prodname ON pe.entity_id = prodname.entity_id AND prodname.attribute_id = 71
  25.                 join fhs_sales_flat_order o on o.increment_id = so.order_id
  26.                 JOIN fhs_sales_flat_order_address sab      ON o.billing_address_id = sab.entity_id
  27.                 JOIN fhs_sales_flat_order_address sa       ON o.shipping_address_id = sa.entity_id
  28.                 where so.parent_id is null
  29.                 and so.suborder_id = {$suborder_id}
  30.                 group by suborder_id, pe.sku;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement