VIXUS Posted September 25, 2010 Share Posted September 25, 2010 Hello!I am working on php script that would enable mine partners to download my pricelist from certain link...It is based on this work: http://www.prestashop.com/forums/viewthread/25318/modules_tiers/module_dexport_catalogue_format_xmlI got it working but but have some problems... script generates huge ammount of products becouse it inputs all existing products, active and non active and it create multiple entries of the same product becouse it is in multiple categories even do it is the same product with its unique product ID.(script is attached)Any help how to purge that data so that php dont generate xml with multiple product entries and dont collect inactive products?HELP! pricelist_xml_generator.php 2 Link to comment Share on other sites More sharing options...
rocky Posted September 26, 2010 Share Posted September 26, 2010 You could exclude inactive products by changing: foreach ($products AS $product){ ... } to: foreach ($products AS $product){ if ($product['active']){ ... } } I don't understand the code well enough to remove multiple entries. Link to comment Share on other sites More sharing options...
VIXUS Posted September 26, 2010 Author Share Posted September 26, 2010 Thanx mate, this helped to reduce pricelist more than 50%...If someone know how to reduce multiple products, please help! Link to comment Share on other sites More sharing options...
VIXUS Posted September 26, 2010 Author Share Posted September 26, 2010 OK,i'w found some examples on forum and i put together fully functional script so here it is if someone needs it. <?php $langHr = 7; include(dirname(__FILE__).'/config/config.inc.php'); require_once(dirname(__FILE__).'/init.php'); error_reporting(0); $p=Product::getProducts(7, 0, 0, 'id_product', 'desc', false); // number 7 is id of language in database $products=Product::getProductsProperties(7, $p); // number 7 is id of language in database header("Content-Type: text/xml"); echo '<?xml version="1.0" encoding="utf-8"?> '; foreach ($products as $row) { if ($row['active']){ $img=Product::getCover($row['id_product']); echo ' '.str_replace("&", "&", $row['id_product']).' '.str_replace("&", "&", $row['name']).' '.str_replace("&", "and", strip_tags($row['description_short'])).' '.($row['price']*1).' '.str_replace("&", "&", $row['quantity']).' '.str_replace("&", "&", $row['category']).' <link>http://www.site.com'.$row['link'].'</link> http://www.site.com/shop/'.$shopUrl.'img/p/'.$row['id_product'].'-'.$img['id_image'].'.jpg '; } } echo ''; ?> put this php file into your shop folder and thats it... just send that url to your partners and they are ready to receive your data. 1 Link to comment Share on other sites More sharing options...
VIXUS Posted September 27, 2010 Author Share Posted September 27, 2010 Huh... still some help needed.this line '.str_replace("&", "&", $row['quantity']).' works correct and returns exact number of products on stock.But i need to change quantity as number into word "AVAILABLE" when quantity number is more than 0.Can someone halp? Link to comment Share on other sites More sharing options...
rocky Posted September 27, 2010 Share Posted September 27, 2010 So you want "Available" and "Out of Stock" instead of the quantity? Try using the following code: '.($row['quantity'] > 0 ? 'Available' : 'Out of Stock').' Link to comment Share on other sites More sharing options...
VIXUS Posted September 28, 2010 Author Share Posted September 28, 2010 Thanx, rocky! Link to comment Share on other sites More sharing options...
lmarcelocc Posted October 7, 2010 Share Posted October 7, 2010 Hi,i put this php file in my public_html directory, but now how I download de xml list of my products? Link to comment Share on other sites More sharing options...
Thommy Posted November 15, 2010 Share Posted November 15, 2010 This worked out great.But does anyone know how I can get swedish letters in the feed. The letters å, ä and ö is replaced with andouml; for ö. And so on. Link to comment Share on other sites More sharing options...
shmeksi Posted November 24, 2010 Share Posted November 24, 2010 Thanks to VIXUS. Link to comment Share on other sites More sharing options...
istox Posted December 7, 2010 Share Posted December 7, 2010 Hello!But how can be added option to this php? Link to comment Share on other sites More sharing options...
armadillo Posted June 9, 2011 Share Posted June 9, 2011 Hi i tryed the php code but the page just appears below:This XML file does not appear to have any style information associated with it. The document tree is shown below.What is the problem Link to comment Share on other sites More sharing options...
rocky Posted June 9, 2011 Share Posted June 9, 2011 It's normal for IE to say that before displaying the XML in the browser. That doesn't mean there's a problem with the XML. Open it using Notepad or another editor instead if you don't want to see that text. Link to comment Share on other sites More sharing options...
armadillo Posted June 10, 2011 Share Posted June 10, 2011 I am receving thes message after i upload the file on root and visit the link. How i will see the xml data of my website. Did't i have top visit the link with that code? Link to comment Share on other sites More sharing options...
rocky Posted June 10, 2011 Share Posted June 10, 2011 Just download it off your server and use an editor like Notepad to view the entire XML file. If you open it in your IE, you will see a collapsed XML tree that can be expanded instead of the full XML file. Link to comment Share on other sites More sharing options...
armadillo Posted July 4, 2011 Share Posted July 4, 2011 Hi, i have a XML creation file like at attachment. Everything is ok just Category is missing and need full path for images like http://www.xxxxxxxx.com/........./3467.jpgAny answer for this please xml.php Link to comment Share on other sites More sharing options...
rocky Posted July 5, 2011 Share Posted July 5, 2011 So you want to change the product image URL from 3467.jpg to http://www.xxxxxxxx.com/.../3467.jpg? Looking at that code, I think you should change: $product_image_url_text = $dom->createTextNode($image['id_image'].".jpg"); to: $product_image_url_text = $dom->createTextNode($link->getImageLink($productinfo->link_rewrite, $image['id_image'])); Link to comment Share on other sites More sharing options...
armadillo Posted July 5, 2011 Share Posted July 5, 2011 Thanks, for category there is an code below but i want to be default category, what must changes be? // Category$categoryname = $dom->createElement("Category");$product->appendChild($categoryname);$categoryname_text = $dom->createTextNode($category->name); $categoryname->appendChild($categoryname_text); Link to comment Share on other sites More sharing options...
rocky Posted July 5, 2011 Share Posted July 5, 2011 Something like the following should work: // Default Category $defaultCategory = new Category($productinfo->id_category_default, $cookie->id_lang); $categoryname = $dom->createElement("Category"); $product->appendChild($categoryname); $categoryname_text = $dom->createTextNode($defaultCategory->name); $categoryname->appendChild($categoryname_text); Link to comment Share on other sites More sharing options...
armadillo Posted July 5, 2011 Share Posted July 5, 2011 Thanks but not worked any changes? Link to comment Share on other sites More sharing options...
rocky Posted July 6, 2011 Share Posted July 6, 2011 I've changed the angle quotes to straight quotes in my code above. Maybe that will fix the problem. Link to comment Share on other sites More sharing options...
armadillo Posted July 6, 2011 Share Posted July 6, 2011 Sorry but not solved, the category is coming just with that text Link to comment Share on other sites More sharing options...
rocky Posted July 6, 2011 Share Posted July 6, 2011 I've changed id_default_category above to id_category_default. Hopefully, now it will work. Link to comment Share on other sites More sharing options...
armadillo Posted July 6, 2011 Share Posted July 6, 2011 it is OK now, thanks for your fast help Link to comment Share on other sites More sharing options...
Hashishim Posted July 9, 2011 Share Posted July 9, 2011 Can someone please explain to me how to implement the php files that you guys attached. I really need this as I have over 2500 Items on my online store. And i need a quick and easy way of getting a pricelist. With their Categories (All Categories), Their Price (Including if i used a discounted price), their reference number and Product Item/Description. and the image if possible. I downloaded the attached files and put it in a php but i get an error:The ERROR:Warning: include(../../config/config.inc.php) [function.include]: failed to open stream: No such file or directory in /home/kamjocoz/public_html/gct/pricelistproper.php on line 2Warning: include(../../config/config.inc.php) [function.include]: failed to open stream: No such file or directory in /home/kamjocoz/public_html/gct/pricelistproper.php on line 2Warning: include() [function.include]: Failed opening '../../config/config.inc.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/kamjocoz/public_html/gct/pricelistproper.php on line 2Warning: include(../../init.php) [function.include]: failed to open stream: No such file or directory in /home/kamjocoz/public_html/gct/pricelistproper.php on line 3Warning: include(../../init.php) [function.include]: failed to open stream: No such file or directory in /home/kamjocoz/public_html/gct/pricelistproper.php on line 3Warning: include() [function.include]: Failed opening '../../init.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/kamjocoz/public_html/gct/pricelistproper.php on line 3Category ID is missing Please help me Link to comment Share on other sites More sharing options...
sakrafanas Posted December 13, 2012 Share Posted December 13, 2012 (edited) Hello, script works just fine, but i get wrong image path because i am using PrestaShop 1.4.8.2 and new image file system. Script generates this image path: http://www.mydomain....57-56-large.jpg But images are located in: http://www.mydomain....17-32-large.jpg What do i need to change in this line: echo "<img>http://www.mydomain.com".__PS_BASE_URI__."img/p/".$image[0]['id_product']."-".$image[0]['id_image']."-large.jpg</img>\n"; Thanx! Edited December 13, 2012 by sakrafanas (see edit history) Link to comment Share on other sites More sharing options...
Alister91 Posted December 13, 2012 Share Posted December 13, 2012 got it working but but have some problems... script generates huge ammount of products becouse it inputs all existing products, active and non active and it create multiple entries of the same product becouse it is in multiple categories even do it is the same product with its unique product ID. Link to comment Share on other sites More sharing options...
sakrafanas Posted December 13, 2012 Share Posted December 13, 2012 who can help with getting correct image url? Link to comment Share on other sites More sharing options...
sakrafanas Posted December 27, 2012 Share Posted December 27, 2012 People, who can help with my problem? Link to comment Share on other sites More sharing options...
perusi Posted June 20, 2013 Share Posted June 20, 2013 do you have anything for PS 1.5.3 ? thanks Link to comment Share on other sites More sharing options...
google.al Posted October 15, 2013 Share Posted October 15, 2013 Can someone please explain to me how to implement the php files that you guys attached. I really need this as I have over 2500 Items on my online store. And i need a quick and easy way of getting a pricelist. With their Categories (All Categories), Their Price (Including if i used a discounted price), their reference number and Product Item/Description. and the image if possible. I downloaded the attached files and put it in a php but i get an error: The ERROR: Warning: include(../../config/config.inc.php) [function.include]: failed to open stream: No such file or directory in /home/kamjocoz/public_html/gct/pricelistproper.php on line 2 Warning: include(../../config/config.inc.php) [function.include]: failed to open stream: No such file or directory in /home/kamjocoz/public_html/gct/pricelistproper.php on line 2 Warning: include() [function.include]: Failed opening '../../config/config.inc.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/kamjocoz/public_html/gct/pricelistproper.php on line 2 Warning: include(../../init.php) [function.include]: failed to open stream: No such file or directory in /home/kamjocoz/public_html/gct/pricelistproper.php on line 3 Warning: include(../../init.php) [function.include]: failed to open stream: No such file or directory in /home/kamjocoz/public_html/gct/pricelistproper.php on line 3 Warning: include() [function.include]: Failed opening '../../init.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/kamjocoz/public_html/gct/pricelistproper.php on line 3 Category ID is missing Please help me Replace the two firtst rows: include('../../config/config.inc.php'); include('../../init.php'); with these: include(dirname(__FILE__).'/config/config.inc.php'); require_once(dirname(__FILE__).'/init.php'); Link to comment Share on other sites More sharing options...
phemto Posted April 11, 2016 Share Posted April 11, 2016 this code is no working for me it's showing error at line 5 column 2 and also when i leave {spam filter] its telling me syntax error, unexpected 'echo' (T_ECHO) Link to comment Share on other sites More sharing options...
Recommended Posts