Striker Production Posted November 10, 2021 Share Posted November 10, 2021 (edited) NOTICE: You have to set the value of $directory! For cPanel: In cPanel in the right section of 'GENERAL INFORMATION', respectively 'Home Directory'. For localhost you have to set with location of files (ex:C:\xampp\htdocs\prestashop), and you will have to delete all the "/public_html" strings from connect_prestashop function. <style> @import url('https://fonts.googleapis.com/css2?family=Roboto&display=swap'); table,tr,td {border:1px solid #2F3136;text-align:left;font-size:11px;} th {background:#2F3136;min-width:130px;text-align:left;} body {background:#36393F;color:white;font-family: 'Roboto', sans-serif;} .img_link {color: #fff;font-weight: 400;background: #5865F2;padding: 2px;margin: 1px;border-radius: 4px;text-decoration: unset;} .product_link {font-weight: 500;text-decoration: unset;text-shadow: 1px 1px 1px black;color: white;} .logo{border-radius: 1200px;width: 150px;max-width: 40px;float: right;} .warning1{background: #8d2828;text-shadow: 2px 1px 2px black;} .warning2{background: #e7b850;text-shadow: 2px 1px 2px black;} </style> <body> <a target="_blank" href="https://www.prestashop.com/forums/profile/1677932-striker-production/"><image class="logo" src="https://www.prestashop.com/forums/uploads/monthly_2021_05/youtube_logo_1k_steam_background(2).thumb.jpg.d04453c1afea24b8e39dff612d80655b.jpg"></a> <?php // START FILE $debug=1; $directory='/home/'; //It is located in cPanel in the right section of 'GENERAL INFORMATION', respectively 'Home Directory'. /* <-----------------Import Functions / Classes / DB from Prestashopp ----------------->*/ function connect_prestashop($directory,$debug){ /* <- We import configurations and functions of the site -> */ /* <- /home.../public_html/ - FTP HOST Location-> */ include($directory.'/public_html/config/config.inc.php'); include($directory.'/public_html/init.php'); include($directory.'/public_html/controllers/admin/AdminImportController.php'); if($debug==1) {echo '<p style="background:#2F3136; padding: 10px; border-radius: 25px;color:#48DB60;width: fit-content;">Connected to Prestashop</p>';} } connect_prestashop($directory,$debug); function dispaly_products_prestashop($directory,$debug){ $id_lang=(int)Context::getContext()->language->id; $start=0; $limit=10000; $order_by='id_product'; $order_way='ASC'; $id_category = false; $only_active =true; $context = null; $check="1"; $all_products=Product::getProducts($id_lang, $start, $limit, $order_by, $order_way, $id_category , $only_active , $context = null); echo '<table><tr><th>Product</th><th>Images</th><th>Price</th><th>Stock</th><th>Description</th><th>Short_Description</th><th>EAN13</th></tr>'; foreach ($all_products as $product) { $id_product = $product[id_product]; $url_product =Context::getContext()->link->getProductLink($id_product); $images = Image::getImages($id_lang, $product['id_product'], $idProductAttribute = null); $list_images = array(); foreach ($images as $img) { $link = new Link(); $image = new Image($img['id_image']); $image_url = _PS_BASE_URL_._THEME_PROD_DIR_.$image->getExistingImgPath().".jpg"; array_push($list_images,$image_url); } echo '<tr>'; echo '<td><a target="_blank" class="product_link" href="'.$url_product.'">'.$product[name].'</a></td>'; echo '<td>'; for ($i=0;$i<count($list_images);$i++) {echo '<a target="_blank" class="img_link" href="'.$list_images[$i].'">Image_'.$i.'<a> ';} echo '</td>'; if(($debug==1) and ($product[price]=='0.000000')) {echo '<td class="warning2">'.$product[price].'</td>';} else {echo '<td>'.$product[price].'</td>';} if(($debug==1) and ($product[quantity]=='0')) {echo '<td class="warning1">'.$product[quantity].'</td>';} elseif(($debug==1) and ((int)$product[quantity]<3)) {echo '<td class="warning2">'.$product[quantity].'</td>';} else {echo '<td>'.$product[quantity].'</td>';} echo '<td>'.$product[description].'</td>'; echo '<td>'.$product[description_short].'</td>'; if(($debug==1) and ($product[ean13]=='')) {echo '<td class="warning2">'.$product[ean13].'</td>';} else{echo '<td>'.$product[ean13].'</td>';} echo '</tr>'; } } dispaly_products_prestashop($directory,$debug); // FINAL FILE ?> </body> With this PHP script you can export all products with name, url, images, price, stock, description, summary, ean13. It is not optimized for products with combinations. Can be use as a feed with a cronjob. Untitled.mp4 For all images url extract from product: $images = Image::getImages($id_lang, $product['id_product'], $idProductAttribute = null); $list_images = array(); foreach ($images as $img) { $link = new Link(); $image = new Image($img['id_image']); $image_url = _PS_BASE_URL_._THEME_PROD_DIR_.$image->getExistingImgPath().".jpg"; array_push($list_images,$image_url); } Edited November 10, 2021 by Striker Production (see edit history) Link to comment Share on other sites More sharing options...
Knowband Plugins Posted November 15, 2021 Share Posted November 15, 2021 We suggest you, use the PS default export product data functionality. Image for your reference: https://nimb.ws/evVioR Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now