Slide show

Prestashop Οδηγός σύνδεση του eShop σας με Skroutz & Bestprice





Προσοχή !!!  Το άρθρο αυτό απευθύνεται σε προχωρημένους χρήστες με γνώσεις PHP , ειδικά σε ευαισθητα θέματα e-shop απευθυνθείτε σε ειδικό  για τις αλλαγές !!!

Βλέπετε τον πλήρη κώδικα για ένα open source module σε php που παράγει το xml για skroutz.gr και bestprice.gr
Το μόνο που πρέπει να αλλάξει κάποιος είναι το example με το όνομα από το κατάστημα του. 
Είναι για prestashop 1.7 .
Το συγκεκριμένο είναι για μαγαζί με εσώρουχα. Οπότε έχουμε μέγεθος σουτιέν που είναι συνδυασμός δύο μεγεθών.
Με λίγες αλλαγές μπορεί να το βάλει κάποιος σε ότι κατάστημα θέλει.

Preview:
<?php
$databaseConfig = include 'app/config/parameters.php';

$servername = $databaseConfig[parameters][database_host];
$username = $databaseConfig[parameters][database_user];
$password = $databaseConfig[parameters][database_password];
$database = $databaseConfig[parameters][database_name];
// Create connection
$link = mysqli_connect("$servername", "$username", "$password", "$database");

//set charset
mysqli_set_charset($link, "utf8");

/* check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}

$sql = "select
p.id_product as Product_id,
concat(m.name,' ',pl.name) as Product_name,
group_concat(distinct case when agl.id_attribute_group <> '6' and agl.id_attribute_group <> '5' and agl.id_attribute_group <> '4' then pal.name else null end order by agl.id_attribute_group desc separator ',') AS size,
group_concat(case when agl.id_attribute_group = '5' or agl.id_attribute_group = '4' then pal.name else null end order by agl.id_attribute_group desc separator ',') AS bra_size,
group_concat(distinct case when agl.id_attribute_group = '6' then pal.name else null end order by agl.id_attribute_group desc separator ',') AS color,
sa.quantity as quantity,
round((p.price-(p.price*sp.reduction))*1.24,2) as Price,
p.reference as MPN,
m.name as manufacturer,
concat('https://','example.gr','/el/',cl.link_rewrite,'/',p.id_product,'-',pac.id_product_attribute,'-',pl.link_rewrite,'.html') as Product_Link,
concat( 'https://example.gr/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 Image_Link,
(select group_concat('https://example.gr/img/p/',mid(im2.id_image,1,1),'/', 
 if (length(im2.id_image)>1,concat(mid(im2.id_image,2,1),'/'),''),
 if (length(im2.id_image)>2,concat(mid(im2.id_image,3,1),'/'),''),
 if (length(im2.id_image)>3,concat(mid(im2.id_image,4,1),'/'),''),
 if (length(im2.id_image)>4,concat(mid(im2.id_image,5,1),'/'),''), im2.id_image, '.jpg' separator ',')
 from ps_image as im2 
 where im2.position > '1' and im2.id_product = p.id_product) AS extra_images,
(select group_concat(cl.name order by c2.level_depth asc separator ' > ')
    from ps_category_lang as cl
    join ps_category as c2 on c2.id_category = cl.id_category
    where c2.nleft <= c.nleft and c2.nright >= c.nright and cl.id_lang= '2' and c2.id_category > '2') as category_path
from ps_product as p
left join ps_category_lang as cl on cl.id_category = p.id_category_default and cl.id_lang = '2'
left join ps_product_lang as pl on pl.id_product = p.id_product
left join ps_stock_available as sa on sa.id_product = p.id_product
left join ps_category as c on c.id_category = p.id_category_default
left join ps_manufacturer as m on p.id_manufacturer = m.id_manufacturer
left join ps_image as im on im.id_product = p.id_product and im.position = '1'
left join ps_product_attribute as pa on p.id_product = pa.id_product
left join ps_product_attribute_combination as pac on pac.id_product_attribute = pa.id_product_attribute
left join ps_attribute_lang as pal on pal.id_attribute = pac.id_attribute and pal.id_lang = '2'
left join ps_attribute as a on a.id_attribute = pal.id_attribute
left join ps_attribute_group_lang agl on agl.id_attribute_group = a.id_attribute_group and agl.id_lang = '2'
left join ps_specific_price as sp on sp.id_product = p.id_product
where pl.id_lang = '2' and p.active = '1' and sa.id_product_attribute = pa.id_product_attribute
group by p.id_product
order by p.id_product;";

header("Content-Type:text/xml; charset=utf-8");
print '<?xml version="1.0" encoding="UTF-8"?>';
print '<example>';
print '<created_at>' . date("Y-m-d H:m") . '</created_at>';
print '<products>';

/*
if ($result = mysqli_query($link, $sql)) {
    printf("Select returned %d rows.\n", mysqli_num_rows($result));
  
}
*/

$result = mysqli_query($link, $sql);

// Check result
// This shows the actual query sent to MySQL, and the error. Useful for debugging.
if (!$result) {
    $message  = 'Invalid query: ' . mysqli_error($link) . "\n";
    $message .= 'Whole query: ' . $sql;
    die($message);
}
while ($row = $result->fetch_object()) {
 
 $availabilty="Κατόπιν Παραγγελίας";
 $instock="N";
 $quantity=$row->quantity;
 if($quantity > 0) {
  $availabilty="Παράδοση 1 έως 3 ημέρες";
  $instock="Y";
 }
 $colors=$row->color;
 $color=explode(",", $colors);
 
 $temp_size=$row->size;
 
 if(!empty($temp_size)){
  $size = $temp_size;
 }else {
  $temp_brasizes = $row->bra_size;
  $brasizes = explode(",", $temp_brasizes);
  $size_elements = count($brasizes);  
  $size="";
  for($i=0; $i<=($size_elements/2)-1; $i++) {
   if($i < ($size_elements/2)-1){
    $size= $size . $brasizes[$i] . $brasizes[$i+($size_elements/2)] . ',';
   }else{
    $size= $size . $brasizes[$i] . $brasizes[$i+($size_elements/2)];
   }    
  }
  
 }
 $temp_name=$row->Product_name;
 if (strpos(strtolower($temp_name), strtolower($color[0])) !== false) {
    $name=$temp_name;
 }else{
  $name=$temp_name . ' ' .  $color[0];
 }

 $im_count=0; 
 $temp_extra_images=$row->extra_images;
 if(!empty($temp_extra_images)){
  $extra_image = explode(",", $temp_extra_images);
  $im_count=count($extra_image);
 }
 
 
 print '<product>';
 print '<id>' . $row->Product_id . '</id>';
    print '<name><![CDATA[' . $name . ']]></name>';
 print '<link><![CDATA[' . $row->Product_Link . ']]></link>';
 print '<image><![CDATA[' . $row->Image_Link . ']]></image>';
 if($im_count>0) {
  for($i=0; $i<=$im_count-1; $i++) {
    print '<additional_image><![CDATA[' . $extra_image[$i] . ']]></additional_image>';
  }
 }
 print '<category><![CDATA[' . $row->category_path . ']]></category>';
 print '<price_with_vat>' . $row->Price . '</price_with_vat>';
 print '<mpn>' . $row->MPN . '</mpn>';
 print '<manufacturer><![CDATA[' . $row->manufacturer . ']]></manufacturer>';
 print '<instock>' . $instock . '</instock>';
 print '<color>' . $color[0] . '</color>';
 print '<size>' . $size . '</size>';
 print '<availability>' . $availabilty . '</availability>'  ;  
   print "</product>";
}

print "</products>";
print "</example>";
/* free result set */
mysqli_free_result($result);

mysqli_close($link);

?>

Συγγραφέας sanctusmob
Resource https://www.prestashop.com/forums/
Για ότι απορίες έχετε σχετικά με τον κώδικα απευθυνθείτε στο ειδικό για αυτό το θέμα foroum στο παραπάνω link


Prestashop Tuorials



Bonus Περιεχόμενο


Μια λίστα με δωρεάν χρήσιμα πρόσθετα τα οποία μας διευκολύνουν την ζωή και γενικά την λειτουργία του καταστήματος μας.
Έτσι δημιουργώντας αυτή την λίστα, καινούργιοι χρήστες αλλά και παλιοί της πλατφόρμας θα έχουν μια συγκεντρωτική λίστα για να μην ψάχνονται σε όλο το forum ή σε άλλα forum.




ΠΡΟΣΟΧΗ !!! Για προχωρημένους με γνώσεις HTML & PHP

Πώς μπορεί στο eshop του να βάζει & τιμή καταστήματος. Δουλεύει σε prestashop 1.7x. 
---
Κάνετε εγκατάσταση το module. 
Μετά αυτό που χρειάζεται να κάνετε είναι να ανοίξετε το αρχείο product.tpl
domain_name_root\themes\THEME_NAME\templates\catalog\product.tpl 
line 84 κάπου εκεί τοποθετήστε
{hook h='displayStorePrice' product=$product}

{block name='product_prices'}
            {include file='catalog/_partials/product-prices.tpl'}
     {hook h='displayStorePrice' product=$product}
{/block}

       

Reblog https://www.prestashop.com/forums/

NEW !!! Μπορείτε να συμμετέχετε ενεργά στην ομάδα wordpress911 να κάνετε και να απαντάτε ερωτήσεις να ανεβάζετε άρθρα και video κάντε εγγραφή » Here

Links: Μορείτε να κατεβάσετε τα καλύτερα WordPress Woocommerce Templates ΕΔΩ


Δεν υπάρχουν σχόλια:

Δημοσίευση σχολίου


Thank you for contacting us