Darkkz Posted March 11, 2014 Share Posted March 11, 2014 Salutari, A reusit cineva sa faca un export al produselor in format .csv pentru 2 parale? Daca da imi poate spune si mie cum / poate lasa scriptul aici? Cam asa trebuie sa arate .csv-ul: "titlu","descriere","mesaj scurt(poate fi si vid)","pret","categorie","subcategorie(poate fi si vid)","url","urluri imagine","id produs","generare link text(0 sau 1)","brand(poate fi si vid)","in stoc(0 sau 1)","alte date in format JSON sau YAML(poate fi si vid)" Multumesc Link to comment Share on other sites More sharing options...
iuliann Posted March 14, 2014 Share Posted March 14, 2014 Cred ca ar trebui sa le ceri lor un script... De exemplu la shopmania au scriptul lor proprietar... Probabil si la ei ar trebui sa fie ceva de genul asta. Link to comment Share on other sites More sharing options...
zillo Posted March 25, 2014 Share Posted March 25, 2014 Servus, Cateva intrebari: Ce versiune PS folosesti? Cum ai textele salvate in baza de date: cu caractere romanesti sau fara ? Vrei sa exporti toate produsele sau doar anumite categorii? Am facut o implementare, un controller care extinde un alt controller Prestashop, un alt fisier php care defineste calea de acces si executa controller-ul si un template pentru export. Le pot impacheta intr-un modul. Daca doresti putem discuta. Spor, VV 1 Link to comment Share on other sites More sharing options...
lav3pa Posted April 2, 2014 Share Posted April 2, 2014 Servus, Cateva intrebari: Ce versiune PS folosesti? Cum ai textele salvate in baza de date: cu caractere romanesti sau fara ? Vrei sa exporti toate produsele sau doar anumite categorii? Am facut o implementare, un controller care extinde un alt controller Prestashop, un alt fisier php care defineste calea de acces si executa controller-ul si un template pentru export. Le pot impacheta intr-un modul. Daca doresti putem discuta. Spor, VV Sunt si eu interesat de ceva de genul. Imi poti da detalii ? 1 Link to comment Share on other sites More sharing options...
zillo Posted April 4, 2014 Share Posted April 4, 2014 @lav3pa Nu mi-e clar de unde doresti detaliile la care te referi, de la mine sau de la initiatorul topicului. In cazul in care le astepti de la mine, subliniez ca e necesar sa stiu versiunea PS si celelalte amanunte solicitate si in postul anterior. VV Link to comment Share on other sites More sharing options...
nzecheru Posted April 30, 2014 Share Posted April 30, 2014 @lav3pa Nu mi-e clar de unde doresti detaliile la care te referi, de la mine sau de la initiatorul topicului. In cazul in care le astepti de la mine, subliniez ca e necesar sa stiu versiunea PS si celelalte amanunte solicitate si in postul anterior. VV Salut, Versiunea e 1.6, fara diacritice, toate produsele. Ai cumva un modul disponibil pentru asta? Multumesc. Link to comment Share on other sites More sharing options...
zillo Posted May 1, 2014 Share Posted May 1, 2014 Verific și fac modificările pentru versiunea 1.6. Pentru generarea feed-ului va fi necesar să setezi categoria din care este construit feed-ul de produse. În acest fel se pot gestiona individual oricare dintre produsele care sunt incluse în feed. Opinia mea este că modul de lucru oportun este creearea și folosirea unei categori exclusiv pentru construcția feed-ului. Se creează o categorie specială dedicată feed-ului, categorie care nu este vizibilă în magazin. În această categorie se adaugă toate produsele pe care operatorul magazinului dorește să le includă în feed. ATENȚIE: aceasta nu trebuie să fie categoria implicită a nici unui produs. (dacă această atenționare nu este clară, solicitați detalii). Am încercat să reduc la minim numărul de setări necesare. Se mai poate seta modul de construcție, adică dacă feed-ul este construit în format standard ASCI sau cu caractere românești(diacritice) format UTF8. Mai am câteva idei, dar aștept și eventuale sugestii. @nzecheru te contactez pe PM zilele urmatoare Link to comment Share on other sites More sharing options...
MihaiAlex Posted October 29, 2014 Share Posted October 29, 2014 A reusit cineva pana la urma sa genereze un fisier CSV dupa formatul cerut de 2parale? Din pacate eu sunt cam certat cu SQL si mi-am batut deja capul cateva ore cu el. Din ce am inteles pana acum informatile cerute de 2parale se regasesc in mai multe tabele.Descrierea este intr-un tabel iar pretul in altu.Daca are cineva o interogare SQL care sa extraga toate informatile ar fi perfect. Link to comment Share on other sites More sharing options...
ilisiaraul Posted November 11, 2014 Share Posted November 11, 2014 Reuseste careva? Putem modifica scripturile cauti etc? Link to comment Share on other sites More sharing options...
MihaiAlex Posted November 11, 2014 Share Posted November 11, 2014 Am scos o interogare dar platforma de la ei inca da eroare la fisier. Link to comment Share on other sites More sharing options...
ilisiaraul Posted November 14, 2014 Share Posted November 14, 2014 Am scos o interogare dar platforma de la ei inca da eroare la fisier. Lucrez la, Ex: SQL Manager > Ad new > Export CSV. SELECT DISTINCT p.id_product, pl.name AS 'Name', pl.description_short AS 'Short description', pl.description AS 'Description', p.price AS 'Price tax excl.', p.id_category_default AS 'Default Category', root category pl.link_rewrite AS 'URL rewritten', p.id_product AS 'ID', 0 p.reference,m.name AS manufacturer p.active AS 'Active (0/1)', FROM ps_product p INNER JOIN ps_product_lang pl ON p.id_product = pl.id_product LEFT JOIN ps_supplier_lang sl ON p.id_supplier = sl.id_supplier LEFT JOIN ps_manufacturer_lang ml ON p.id_manufacturer = ml.id_manufacturer Dar momentan caut sa ii gasesc forma buna si sa mearga.. Link to comment Share on other sites More sharing options...
ilisiaraul Posted November 15, 2014 Share Posted November 15, 2014 Mai trebuie bagat in cod categories and url to product. Aproape e gata SELECT pl.name AS 'Name', pl.description_short AS 'Short description', pl.description AS 'Description', p.price AS 'Price tax excl.', p.id_product AS 'ID', p.online_only AS 'Available online only', p.active AS 'Active (0/1)', pl.available_later AS 'Text when backorder allowed', concat( 'http://', ifnull( conf.value, 'siteaddress.ro' ) , '/img/p/',mid(p.id_product,1,1),'/', if (length(p.id_product)>1,concat(mid(p.id_product,2,1),'/'),''),if (length(p.id_product)>2,concat(mid(p.id_product,3,1),'/'),''),if (length(p.id_product)>3,concat(mid(p.id_product,4,1),'/'),''),if (length(p.id_product)>4,concat(mid(p.id_product,5,1),'/'),''), p.id_product, '.jpg' ) AS url_image FROM ps_configuration conf, ps_product p INNER JOIN ps_product_lang pl ON p.id_product = pl.id_product LEFT JOIN ps_supplier_lang sl ON p.id_supplier = sl.id_supplier LEFT JOIN ps_manufacturer_lang ml ON p.id_manufacturer = ml.id_manufacturer WHERE conf.name = 'PS_SHOP_DOMAIN' Link to comment Share on other sites More sharing options...
MihaiAlex Posted November 17, 2014 Share Posted November 17, 2014 SELECT pl.name, pl.description_short AS "Descriere", " " AS 'Descriere scurta', p.price AS 'Pret', GROUP_CONCAT(DISTINCT(cl.name)) AS 'Categorie',pl.link_rewrite AS 'URL', concat( 'http://mischa.ro/img/p/',mid(im.id_image,1,1),'/', if (length(im.id_image)>1,concat(mid(im.id_image,2,1),'/'),''),if (length(im.id_image)>2,concat(mid(im.id_image,3,1),'/'),''),if (length(im.id_image)>3,concat(mid(im.id_image,4,1),'/'),''),if (length(im.id_image)>4,concat(mid(im.id_image,5,1),'/'),''), im.id_image, '.jpg' ) AS 'url_imagini', p.id_product AS 'ID produs', "" AS 'Generare link text', " " AS 'Brand', p.on_sale AS 'In stoc (0/1)', " " AS 'alte date in format JSON sau YAML(optional)' FROM ps_product p LEFT JOIN ps_product_lang pl ON (p.id_product = pl.id_product) LEFT JOIN ps_category_product cp ON (p.id_product = cp.id_product) LEFT JOIN ps_category_lang cl ON (cp.id_category = cl.id_category) LEFT JOIN ps_category c ON (cp.id_category = c.id_category) LEFT JOIN ps_product_tag pt ON (p.id_product = pt.id_product) LEFT JOIN ps_image im ON p.id_product = im.id_product WHERE pl.id_lang = 1 AND cl.id_lang = 1 AND p.id_shop_default = 1 AND c.id_shop_default = 1 GROUP BY p.id_product Vezi daca te ajuta ceva de aici Link to comment Share on other sites More sharing options...
ilisiaraul Posted November 18, 2014 Share Posted November 18, 2014 SELECT pl.name, pl.description_short AS "Descriere", " " AS 'Descriere scurta', p.price AS 'Pret', GROUP_CONCAT(DISTINCT(cl.name)) AS 'Categorie',pl.link_rewrite AS 'URL', concat( 'http://mischa.ro/img/p/',mid(im.id_image,1,1),'/', if (length(im.id_image)>1,concat(mid(im.id_image,2,1),'/'),''),if (length(im.id_image)>2,concat(mid(im.id_image,3,1),'/'),''),if (length(im.id_image)>3,concat(mid(im.id_image,4,1),'/'),''),if (length(im.id_image)>4,concat(mid(im.id_image,5,1),'/'),''), im.id_image, '.jpg' ) AS 'url_imagini', p.id_product AS 'ID produs', "" AS 'Generare link text', " " AS 'Brand', p.on_sale AS 'In stoc (0/1)', " " AS 'alte date in format JSON sau YAML(optional)' FROM ps_product p LEFT JOIN ps_product_lang pl ON (p.id_product = pl.id_product) LEFT JOIN ps_category_product cp ON (p.id_product = cp.id_product) LEFT JOIN ps_category_lang cl ON (cp.id_category = cl.id_category) LEFT JOIN ps_category c ON (cp.id_category = c.id_category) LEFT JOIN ps_product_tag pt ON (p.id_product = pt.id_product) LEFT JOIN ps_image im ON p.id_product = im.id_product WHERE pl.id_lang = 1 AND cl.id_lang = 1 AND p.id_shop_default = 1 AND c.id_shop_default = 1 GROUP BY p.id_product Vezi daca te ajuta ceva de aici Super. Merci frumos. Vad ca functioneaza link-ul de la poze unde este. O sa incerc sa ii dau de cap. Link to comment Share on other sites More sharing options...
Attrexx Posted March 25, 2015 Share Posted March 25, 2015 Humble bump Aveti vesti legat de o interogare finala si functionala pentru 2parale? Link to comment Share on other sites More sharing options...
lightsb Posted March 26, 2015 Share Posted March 26, 2015 O sugestie ... aici Link to comment Share on other sites More sharing options...
Marius05 Posted May 10, 2015 Share Posted May 10, 2015 (edited) Incercati-l pe acesta, spuneti-mi daca e ok. (PS 1.6) 2parale_csv.php Edited May 10, 2015 by Marius05 (see edit history) 1 Link to comment Share on other sites More sharing options...
kNife77 Posted September 30, 2015 Share Posted September 30, 2015 Am rezolvat FEED 2 PARALE care functioneaza perfect pe prestashop 1.6.0.9. Va pune stoc 1 pt toate produsele, recomand sa le dezactivati manual pe cele cu stoc 0, 2 parale accepta doar stoc 0 si 1. <?php /* ** ** CSV export for PrestaShop ** ** You have to put this file into your webshops main directory, and it will be work. ** */ define ('AK_VERSION', '2.1.7'); define ('AK_CHECK_STOCK', 1); define ('ENGINE_NAME', 'PrestaShop'); // define('_USER_ID_LANG_',1); set_time_limit(0); if (!file_exists('init.php') || !file_exists('config/config.inc.php')) { ak_error('An include file not found. Check the path.'); } include('config/config.inc.php'); require_once('init.php'); if (isset($_GET['ak_check_stock']) && ($_GET['ak_check_stock'] == 0 || $_GET['ak_check_stock'] == 'false')) { define ('AK_CHECK_STOCK_CONST', 0); } else { define ('AK_CHECK_STOCK_CONST', AK_CHECK_STOCK); } try { $query = Db::getInstance()->ExecuteS('SELECT p.id_product FROM ' . _DB_PREFIX_ . 'product p WHERE p.active = 1 '); // "AND quantity > 0" if (!$query) { ak_error('SQL error: ' . mysql_error()); } $lang = (int)Configuration::get('PS_LANG_DEFAULT'); $data = array(); $curreny = Currency::getCurrent(); $cat = new Category(); $root = $cat->getRootCategory(); $categories = array(); $defaultCountry = new Country(Configuration::get('PS_COUNTRY_DEFAULT'), Configuration::get('PS_LANG_DEFAULT')); $id_zone = (int)$defaultCountry->id_zone; $id_carrier = (int)(Configuration::get('PS_CARRIER_DEFAULT')); $carrierTax = Tax::getCarrierTaxRate((int)$id_carrier); $carrier = new Carrier((int)($id_carrier), Configuration::get('PS_LANG_DEFAULT')); foreach ($query as $i => $v) { $product = new Product(intval($v['id_product']),true, $lang); $productCategories = $product->getCategories(); $parents = ""; $category = ""; foreach ($productCategories as $productCategory) { $temp = ak_get_category($productCategory); if ($temp['parents'] > $parents) { $category = $temp['name']; $parents = $temp['parents']; } } $url = $product->getLink(); $img = $product->getCover($product->id); if ($img['id_image'] > 0) { //$image = $link->getImageLink($product->link_rewrite,$product->id . '-' . $img['id_image'],'large'); $image = $link->getImageLink($product->link_rewrite,$product->id . '-' . $img['id_image'],'thickbox_default'); } else { $image = ""; } $price = Product::getPriceStatic($product->id, true, NULL, 6); if (isset(Product::$_taxCalculationMethod) && Product::$_taxCalculationMethod == PS_TAX_INC) { $price = Tools::ps_round($price,2); } else { $price = round($price,2); } $id_produs = $product->id; //$line['manufacturer'] = ak_clean($product->manufacturer_name); $line['name'] = ak_clean($product->name); $line['description'] = str_replace (array("\r\n", "\n", "\r"), '', $line['description']); $line['description'] = strip_tags(ak_clean($product->description,true)); $line['description'] = str_replace(",", " ",$line['description']); // fara virgule $line['description'] = str_replace('"', " ",$line['description']); // fara ghilimele $line['description'] = preg_replace('!\s+!', ' ', $line['description']); $line['description'] = trim($line['description']); $line['mesaj_scurt'] = ''; $line['price'] = $price; $line['category'] = ak_clean($category); $line['subcategorie'] = ''; $line['product_url'] = ak_clean($url); $line['image_url'] = ak_clean($image); $line['id_produs'] = ak_clean($id_produs); $line['link_text'] = 1; $line['brand'] = ''; $line['stock'] = 1; $line['alte_date'] = ''; // $line['ean13'] = ak_clean($product->ean13,false); // $line['upc'] = ak_clean($product->upc,false); // $line['reference'] = ak_clean($product->reference,false); // $line['supplier_reference'] = ak_clean($product->supplier_reference,false); // $line['currency'] = $currency->iso_code; // $line['delivery_price'] = ak_get_delivery_price($price, $product->weight, $id_zone, $id_carrier, $carrierTax, $carrier); // $line['weight'] = $product->weight; if (!AK_CHECK_STOCK_CONST || ((Configuration::get('PS_STOCK_MANAGEMENT') || $product->quantity > 0) && $product->available_for_order)) { $data[] = $line; } } ak_csv_export($data); } catch (Exception $e) { ak_error("Caught exception: " . $e->getMessage()); } function ak_get_delivery_price($price, $weight, $id_zone, $id_carrier, $carrierTax, $carrier) { $shipping_cost = 0; $configuration = Configuration::getMultiple(array('PS_SHIPPING_FREE_PRICE', 'PS_SHIPPING_HANDLING', 'PS_SHIPPING_METHOD', 'PS_SHIPPING_FREE_WEIGHT')); if (isset($configuration['PS_SHIPPING_FREE_PRICE']) && $price >= $configuration['PS_SHIPPING_FREE_PRICE']) { return "FREE"; } if (isset($configuration['PS_SHIPPING_FREE_WEIGHT']) && $weight >= (float)($configuration['PS_SHIPPING_FREE_WEIGHT']) && (float)($configuration['PS_SHIPPING_FREE_WEIGHT']) > 0) { return "FREE"; } if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT) { if ($weight > 0) { $shipping_cost += $carrier->getDeliveryPriceByWeight($weight, $id_zone); } else { return ""; } } else {// by price $shipping_cost += $carrier->getDeliveryPriceByPrice($price, $id_zone); } if (isset($configuration['PS_SHIPPING_HANDLING']) AND $carrier->shipping_handling) $shipping_cost += (float)($configuration['PS_SHIPPING_HANDLING']); if (isset($carrierTax)) $shipping_cost *= 1 + ($carrierTax / 100); return (float)(Tools::ps_round((float)($shipping_cost), 2)); } function ak_get_category($categoryId) { global $categories, $root, $lang; if (!isset($categories[$categoryId])) { $name = ""; $cntParents = 0; if ($categoryId != $root->id_category) { $cat = new Category($categoryId, $lang); $parents = $cat->getParentsCategories(); $cntParents = count($parents); if ($cntParents > 0) { $category = array(); foreach ($parents as $p) { $category[] = $p['name']; } $name = implode(' > ',array_reverse($category)); } } $categories[$categoryId] = array('parents' => $cntParents, 'name' => $name); } return $categories[$categoryId]; } function ak_clean($field,$filter_html = true) { if ($filter_html) { $pattern = array(); $replacement = array(); $pattern[] = "/<[^>]+>/"; $replacement[] = " "; $pattern[] = "/ +/"; $replacement[] = " "; $field = preg_replace($pattern,$replacement,$field); } $from = array('"',"\r","\n","\\"); $to = array('""',""," ",""); return str_replace($from,$to,$field); } function ak_csv_export($data) { ob_start(); //$header = '"titlu","descriere","mesaj_scurt","pret","categorie","subcategorie","url","urluri_imagine","id_produs","link_text","brand","stock","alte_date"'; //echo "$header\n"; foreach ($data as $line) { foreach ($line as $k => $field) { if (!empty($field)) { echo '"'; echo $field; echo '"'; } else { echo '"'; echo $field; echo '"'; } if ($k == 'alte_date') { echo "\n"; } else { echo ','; } } } $filename = basename($_SERVER['SCRIPT_NAME'],'.php'); $length = ob_get_length(); header("Pragma: public"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: public"); header("Content-Type: text/csv"); header("Content-Disposition: attachment; filename={$filename}.csv" ); header("Content-Transfer-Encoding: binary"); header("Content-Length: $length"); ob_end_flush(); exit; } function ak_error($msg) { header('Cache-Control: no-cache'); header('Content-Type: text/html; charset=utf-8'); echo "<html><head><title>Export error (" . VERSION . ")</title></head><body>"; echo "<p style=\"padding:0;margin:50px;text-align:center;font-weight:bold;\">$msg</p>"; echo "</body></html>"; flush(); exit; } ?> 1 Link to comment Share on other sites More sharing options...
razvy Posted October 11, 2015 Share Posted October 11, 2015 Incercati-l pe acesta, spuneti-mi daca e ok. (PS 1.6) Salut, Feed-ul tau este perfect, dar am o rugaminte: poti sa-l faci sa apara si manufacturer-ul? Eu am incercat sa sterg comentariul de la linia //$line['manufacturer'] = ak_clean($product->manufacturer_name); Dar nu merge, scriptul se blocheaza. Am incercat si prin apelare directa de pe web cu www.site.ro/2parale_csv.php si prin import in Excel. Pana la urma a mers o data, dar a durat extreeeeeem de mult si mi-a introdus o coloana goala in loc de manufacturer... De ce oare?!? Merci. Razvy Link to comment Share on other sites More sharing options...
giulaiula Posted February 24, 2016 Share Posted February 24, 2016 Am rezolvat FEED 2 PARALE care functioneaza perfect pe prestashop 1.6.0.9. Va pune stoc 1 pt toate produsele, recomand sa le dezactivati manual pe cele cu stoc 0, 2 parale accepta doar stoc 0 si 1. <?php /* ** ** CSV export for PrestaShop ** ** You have to put this file into your webshops main directory, and it will be work. ** */ define ('AK_VERSION', '2.1.7'); define ('AK_CHECK_STOCK', 1); define ('ENGINE_NAME', 'PrestaShop'); // define('_USER_ID_LANG_',1); set_time_limit(0); if (!file_exists('init.php') || !file_exists('config/config.inc.php')) { ak_error('An include file not found. Check the path.'); } include('config/config.inc.php'); require_once('init.php'); if (isset($_GET['ak_check_stock']) && ($_GET['ak_check_stock'] == 0 || $_GET['ak_check_stock'] == 'false')) { define ('AK_CHECK_STOCK_CONST', 0); } else { define ('AK_CHECK_STOCK_CONST', AK_CHECK_STOCK); } try { $query = Db::getInstance()->ExecuteS('SELECT p.id_product FROM ' . _DB_PREFIX_ . 'product p WHERE p.active = 1 '); // "AND quantity > 0" if (!$query) { ak_error('SQL error: ' . mysql_error()); } $lang = (int)Configuration::get('PS_LANG_DEFAULT'); $data = array(); $curreny = Currency::getCurrent(); $cat = new Category(); $root = $cat->getRootCategory(); $categories = array(); $defaultCountry = new Country(Configuration::get('PS_COUNTRY_DEFAULT'), Configuration::get('PS_LANG_DEFAULT')); $id_zone = (int)$defaultCountry->id_zone; $id_carrier = (int)(Configuration::get('PS_CARRIER_DEFAULT')); $carrierTax = Tax::getCarrierTaxRate((int)$id_carrier); $carrier = new Carrier((int)($id_carrier), Configuration::get('PS_LANG_DEFAULT')); foreach ($query as $i => $v) { $product = new Product(intval($v['id_product']),true, $lang); $productCategories = $product->getCategories(); $parents = ""; $category = ""; foreach ($productCategories as $productCategory) { $temp = ak_get_category($productCategory); if ($temp['parents'] > $parents) { $category = $temp['name']; $parents = $temp['parents']; } } $url = $product->getLink(); $img = $product->getCover($product->id); if ($img['id_image'] > 0) { //$image = $link->getImageLink($product->link_rewrite,$product->id . '-' . $img['id_image'],'large'); $image = $link->getImageLink($product->link_rewrite,$product->id . '-' . $img['id_image'],'thickbox_default'); } else { $image = ""; } $price = Product::getPriceStatic($product->id, true, NULL, 6); if (isset(Product::$_taxCalculationMethod) && Product::$_taxCalculationMethod == PS_TAX_INC) { $price = Tools::ps_round($price,2); } else { $price = round($price,2); } $id_produs = $product->id; //$line['manufacturer'] = ak_clean($product->manufacturer_name); $line['name'] = ak_clean($product->name); $line['description'] = str_replace (array("\r\n", "\n", "\r"), '', $line['description']); $line['description'] = strip_tags(ak_clean($product->description,true)); $line['description'] = str_replace(",", " ",$line['description']); // fara virgule $line['description'] = str_replace('"', " ",$line['description']); // fara ghilimele $line['description'] = preg_replace('!\s+!', ' ', $line['description']); $line['description'] = trim($line['description']); $line['mesaj_scurt'] = ''; $line['price'] = $price; $line['category'] = ak_clean($category); $line['subcategorie'] = ''; $line['product_url'] = ak_clean($url); $line['image_url'] = ak_clean($image); $line['id_produs'] = ak_clean($id_produs); $line['link_text'] = 1; $line['brand'] = ''; $line['stock'] = 1; $line['alte_date'] = ''; // $line['ean13'] = ak_clean($product->ean13,false); // $line['upc'] = ak_clean($product->upc,false); // $line['reference'] = ak_clean($product->reference,false); // $line['supplier_reference'] = ak_clean($product->supplier_reference,false); // $line['currency'] = $currency->iso_code; // $line['delivery_price'] = ak_get_delivery_price($price, $product->weight, $id_zone, $id_carrier, $carrierTax, $carrier); // $line['weight'] = $product->weight; if (!AK_CHECK_STOCK_CONST || ((Configuration::get('PS_STOCK_MANAGEMENT') || $product->quantity > 0) && $product->available_for_order)) { $data[] = $line; } } ak_csv_export($data); } catch (Exception $e) { ak_error("Caught exception: " . $e->getMessage()); } function ak_get_delivery_price($price, $weight, $id_zone, $id_carrier, $carrierTax, $carrier) { $shipping_cost = 0; $configuration = Configuration::getMultiple(array('PS_SHIPPING_FREE_PRICE', 'PS_SHIPPING_HANDLING', 'PS_SHIPPING_METHOD', 'PS_SHIPPING_FREE_WEIGHT')); if (isset($configuration['PS_SHIPPING_FREE_PRICE']) && $price >= $configuration['PS_SHIPPING_FREE_PRICE']) { return "FREE"; } if (isset($configuration['PS_SHIPPING_FREE_WEIGHT']) && $weight >= (float)($configuration['PS_SHIPPING_FREE_WEIGHT']) && (float)($configuration['PS_SHIPPING_FREE_WEIGHT']) > 0) { return "FREE"; } if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT) { if ($weight > 0) { $shipping_cost += $carrier->getDeliveryPriceByWeight($weight, $id_zone); } else { return ""; } } else {// by price $shipping_cost += $carrier->getDeliveryPriceByPrice($price, $id_zone); } if (isset($configuration['PS_SHIPPING_HANDLING']) AND $carrier->shipping_handling) $shipping_cost += (float)($configuration['PS_SHIPPING_HANDLING']); if (isset($carrierTax)) $shipping_cost *= 1 + ($carrierTax / 100); return (float)(Tools::ps_round((float)($shipping_cost), 2)); } function ak_get_category($categoryId) { global $categories, $root, $lang; if (!isset($categories[$categoryId])) { $name = ""; $cntParents = 0; if ($categoryId != $root->id_category) { $cat = new Category($categoryId, $lang); $parents = $cat->getParentsCategories(); $cntParents = count($parents); if ($cntParents > 0) { $category = array(); foreach ($parents as $p) { $category[] = $p['name']; } $name = implode(' > ',array_reverse($category)); } } $categories[$categoryId] = array('parents' => $cntParents, 'name' => $name); } return $categories[$categoryId]; } function ak_clean($field,$filter_html = true) { if ($filter_html) { $pattern = array(); $replacement = array(); $pattern[] = "/<[^>]+>/"; $replacement[] = " "; $pattern[] = "/ +/"; $replacement[] = " "; $field = preg_replace($pattern,$replacement,$field); } $from = array('"',"\r","\n","\\"); $to = array('""',""," ",""); return str_replace($from,$to,$field); } function ak_csv_export($data) { ob_start(); //$header = '"titlu","descriere","mesaj_scurt","pret","categorie","subcategorie","url","urluri_imagine","id_produs","link_text","brand","stock","alte_date"'; //echo "$header\n"; foreach ($data as $line) { foreach ($line as $k => $field) { if (!empty($field)) { echo '"'; echo $field; echo '"'; } else { echo '"'; echo $field; echo '"'; } if ($k == 'alte_date') { echo "\n"; } else { echo ','; } } } $filename = basename($_SERVER['SCRIPT_NAME'],'.php'); $length = ob_get_length(); header("Pragma: public"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: public"); header("Content-Type: text/csv"); header("Content-Disposition: attachment; filename={$filename}.csv" ); header("Content-Transfer-Encoding: binary"); header("Content-Length: $length"); ob_end_flush(); exit; } function ak_error($msg) { header('Cache-Control: no-cache'); header('Content-Type: text/html; charset=utf-8'); echo "<html><head><title>Export error (" . VERSION . ")</title></head><body>"; echo "<p style=\"padding:0;margin:50px;text-align:center;font-weight:bold;\">$msg</p>"; echo "</body></html>"; flush(); exit; } ?> Unde trebuie pus acest cod ? Link to comment Share on other sites More sharing options...
giulaiula Posted February 24, 2016 Share Posted February 24, 2016 Unde trebuie pus acest cod ? Am rezolvat, feed-ul functioneaza 99% mie imi apar produsele ca nu mai sunt pe stock. Aveti idee de ce? Link to comment Share on other sites More sharing options...
Marius05 Posted February 24, 2016 Share Posted February 24, 2016 Verifica daca structura csv-ului generat este corecta. Adica daca ordinea coloanelor este aceeasi ca in exemplul celor de la 2parale Link to comment Share on other sites More sharing options...
ronniee Posted September 16, 2016 Share Posted September 16, 2016 in loc de denumire si descriere pune Array $line['name'] = ak_clean($product->name); $line['description'] = strip_tags(ak_clean($product->description,true)); ceva nu-i place Link to comment Share on other sites More sharing options...
Marius05 Posted September 16, 2016 Share Posted September 16, 2016 Unde e problema, da mai multe informatii. Ai comparat csv-ul geenrat cu csv-ul cerut de ei ? Link to comment Share on other sites More sharing options...
ronniee Posted September 23, 2016 Share Posted September 23, 2016 am luat ultimul script din acest topic si CSV generat incepe cu: "Array","","","150","Home... ar trebui sa fie: //$header = '"titlu","descriere","mesaj_scurt","pret","categorie","subcategorie","url","urluri_imagine","id_produs","link_text","brand","stock","alte_date"'; nu aduce numele si descriere a produsului, nu stiu de ce Link to comment Share on other sites More sharing options...
Marius05 Posted September 23, 2016 Share Posted September 23, 2016 Ce versiune de PS ai ? Link to comment Share on other sites More sharing options...
ronniee Posted September 23, 2016 Share Posted September 23, 2016 1.6.1.4 Link to comment Share on other sites More sharing options...
Marius05 Posted September 27, 2016 Share Posted September 27, 2016 Ti-am facut modificarile, trebuia inserat id-ul limbii (in cazul tau pentru limba romana 3). Sa-mi spui daca este ok. Link to comment Share on other sites More sharing options...
Attrexx Posted January 19, 2017 Share Posted January 19, 2017 Cum putem evita trimiterea tuturor produselor cu stoc 1?Adica aici $line['stock'] = 1; putem pune o variabila care sa 'traga' existenta stocului? Link to comment Share on other sites More sharing options...
Marius05 Posted January 26, 2017 Share Posted January 26, 2017 (edited) $line['stock'] = $product->quantity; Edited January 26, 2017 by Marius05 (see edit history) Link to comment Share on other sites More sharing options...
Geo Burlibasa Posted February 12, 2017 Share Posted February 12, 2017 O solutie foarte buna pentru generarea CSV-urilor pentru comparatoarele de preturi si nu numai, gasiti aici ceva interesant: https://addons.prestashop.com/en/price-comparison/23790-datafeeds-pricero-compariro-shopmaniaro-etc.html 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