I have the following MYSQL query which is creating results from different tables. It is a query which I use to update google-shopping prices.
SELECT C.virtuemart_product_id as 'g:id',
CONCAT(E.product_name ,' ', E.product_s_desc) as title,
CONCAT('http://ift.tt/1H29hyM',I.slug,'/',E.slug,'-detail') as link,
case when G.mf_name = 'empty' then '1' else 'Free shipping' end as description,
case when A.file_url = '' then '' else CONCAT('http://www.website.com/',A.file_url) END as 'g:image_link',
case when D.override = 1 then round (D.product_override_price,2) else round (D.product_price * J.mwst,2) end as 'g:price',
case when G.mf_name = 'empty' then '1' else 'New' end as 'g:condition', CASE WHEN C.published = '1' then 'in stock' END as 'g:availability',
G.mf_name as 'g:brand', C.product_sku as 'g:gtin',CONCAT(C.product_weight,' kg') as 'g:shipping_weight',
J.g_label_1 as 'g:custom_label_0'
from
e6vw2_virtuemart_medias A, e6vw2_virtuemart_product_medias B, e6vw2_virtuemart_products C, e6vw2_virtuemart_product_prices D, e6vw2_virtuemart_products_da_dk E, e6vw2_virtuemart_product_manufacturers F, e6vw2_virtuemart_manufacturers_da_dk G, e6vw2_virtuemart_product_categories H, e6vw2_virtuemart_categories_da_dk I, product_feed_category_g J
where B.virtuemart_product_id >='6'
and C.published = "1"
and C.product_in_stock >= '1'
and B.virtuemart_product_id=C.virtuemart_product_id
and B.virtuemart_product_id=D.virtuemart_product_id
and B.virtuemart_product_id=E.virtuemart_product_id
and B.virtuemart_product_id=F.virtuemart_product_id
and B.virtuemart_product_id=H.virtuemart_product_id
and B.virtuemart_product_id=J.virtuemart_product_id
and A.virtuemart_media_id = B.virtuemart_media_id
and F.virtuemart_manufacturer_id = G.virtuemart_manufacturer_id
and H.virtuemart_category_id=I.virtuemart_category_id
and H.ordering=1
and B.ordering=1
I would like to end up with a xml which will look like this:
<rss version="2.0"
xmlns:g="http://ift.tt/15FVsV8">
<channel>
<title>Google Merchant Datenfeed</title>
<link>website.com</link>
<description>Datafeed for google merchant - </description>
<item><g:id>32</g:id><title>Samsung Galaxy S5 </title><link>http://ift.tt/1H29hyS shipping</description><g:image_link>http://ift.tt/1H29IJv stock</g:availability><g:brand>Samsung</g:brand><g:gtin>7702018851324</g:gtin><g:shipping_weight>0.0000 kg</g:shipping_weight><g:custom_label_0>Smartphone</g:custom_label_0></item>
<item><g:id>33</g:id> ...
</channel>
</rss>
I need to save these results as a XML file on my webspace as soon I run the php file. I found many posts about this issue but none that would manage results from different tables.
I found this guide http://ift.tt/1Jevvv5 however it does not deal with multiple tables and also does not save the results as a file in the end.
Aucun commentaire:
Enregistrer un commentaire