Jump to content
php.lv forumi

Recommended Posts

Posted (edited)

Šo fīču taisīju vienam interneta veikalam, taču, tas interneta veikals vairs nepastāv un tāpēc izdomāju publicēt šo skriptiņu.. nekas liels, bet nu.. gatavs skriptiņš :)

<?php
header("Content-type: text/xml");
// Settings
$website = 'veikals.lv';
// Connection
$link = mysql_connect("localhost", "user", "parole");
$select_db = mysql_select_db("opencart");

// Select
$sql = "SELECT product_description.name, product.product_id, product.price, product.image, category.parent_id, product_to_category.category_id
FROM product
LEFT JOIN product_description ON product.product_id=product_description.product_id
LEFT JOIN product_to_category ON product.product_id=product_to_category.product_id
LEFT JOIN category_description ON product_to_category.category_id=category_description.category_id
LEFT JOIN category ON category.category_id=category_description.category_id";
$result = mysql_query($sql) or die (mysql_error());
$xml_output  = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
$xml_output .= "<root>\n";
$prev_value = 0;
while ($line = mysql_fetch_assoc($result)) {
if ($prev_value != $line['product_id']) { $prev_value = $line['product_id'];
 // Echo
 $parent_id = $line['parent_id'];
 $sql2 = "SELECT name FROM category_description WHERE category_id=$parent_id AND language_id=2";
 $result2 = mysql_query($sql2) or die (mysql_error());
 while($parent_name1 = mysql_fetch_assoc($result2)){ $parent_name = $parent_name1['name']; }
 if(isset($parent_name)) {$parent_symbol = ">";}else{$parent_symbol = "";}

 $category_id = $line['category_id'];
 $sql3 = "SELECT name FROM category_description WHERE category_id=$category_id AND language_id=2";
 $result3 = mysql_query($sql3) or die (mysql_error());
 while($category_name1 = mysql_fetch_assoc($result3)){ $category_name = $category_name1['name']; }

 $xml_output  .= "<item>\n";
 $xml_output  .= "<name>".$line['name']."</name>\n";
 $xml_output  .= "<link>http:///".$website."/index.php?route=product/product&product_id=".$line['product_id']."</link>\n";
 $xml_output  .= "<price>".$line['price']."</price>\n";
 $xml_output  .= "<image>http://".$website.".lv/image/".$line['image']."</image>\n";
 $xml_output  .= "<category>".$category_name."</category>\n";
 $xml_output  .= "<category_full>".$parent_name." ".$parent_symbol." ".$category_name."</category_full>\n";
 $xml_output  .= "<category_link>http:///".$website."/index.php?route=product/category&path=".$line['category_id']."</category_link>\n";
 $xml_output  .= "</item>\n";
}
}
$xml_output .= "</root>";
echo $xml_output;
?>

P.s.

Vajadzētu strādāt perfekti uz kurpirkt.lv un salidzini.lv

P.p.s.

Last modified 15.03.2011 :D

Edited by So sick!
  • 2 months later...
  • 1 year later...
Posted

LV valoda man nav dzimta valoda tas taisnība.

Ja jums grības palidzēt izlabot klūdas es ar prieku izdarīšu to.

Ja jums ir komenti par kodu jūs arī varat to izteikt.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...