Jump to content

Edit History

radek.juthner

radek.juthner

@PrestashopUser03

Hi. Sorry. doesnt work. 

Can you repair my php code? Need to have product with no combination too.

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <meta name="robots" content="noindex,nofollow" />
    <title>Stav skladu</title>
  </head>

<strong>Skladové zásoby aktivních produktů</strong>

<?php
$pripoj = mysqli_connect('localhost', 'user', 'password','database');
mysqli_query($pripoj,"SET NAMES UTF8");


$dotaz = "SELECT\n"
	 . "    p.active,\n"
    . "    p.id_product,\n"
    . "    pa.reference,\n"
    . "    pa.upc,\n"
    . "    pa.price,\n"
    . "    pai.id_image,\n"
    . "    pl.name,\n"
    . "    GROUP_CONCAT(DISTINCT(pal.name) SEPARATOR \", \") as combination,\n"
    . "    pq.quantity\n"
    . "FROM ps_product p\n"
    . "LEFT JOIN ps_product_attribute pa ON (p.id_product = pa.id_product)\n"
    . "LEFT JOIN ps_stock_available pq ON (p.id_product = pq.id_product AND pa.id_product_attribute = pq.id_product_attribute)\n"
    . "LEFT JOIN ps_product_lang pl ON (p.id_product = pl.id_product)\n"
    . "LEFT JOIN ps_product_attribute_combination pac ON (pa.id_product_attribute = pac.id_product_attribute)\n"
    . "LEFT JOIN ps_attribute_lang pal ON (pac.id_attribute = pal.id_attribute)\n"
    . "LEFT JOIN ps_product_attribute_image pai on(pa.id_product_attribute = pai.id_product_attribute)\n"
    . "WHERE pl.id_lang = 3\n"
    . "AND pal.id_lang = 3\n"
    . "GROUP BY pa.reference\n"
    . "ORDER BY p.id_product, pac.id_attribute";  

$vysledek = mysqli_query($pripoj,$dotaz);
?>

<table style="width: 920px; height: 54px;" border="1">
      <tbody>
      <tr>
          <td>ID produktu
          </td>
          <td>Jméno produktu
          </td>
          <td>Varianta
          </td>
          <td>Kód produktu
          </td>
          <td>Množství
          </td>
        </tr>
        <tr>
<?php    

while ($zaznam = MySQLi_Fetch_Array($vysledek)){ 

$id_product=$zaznam["id_product"];
$reference=$zaznam["reference"];
$kombinace=$zaznam["combination"];
$quantity=$zaznam["quantity"];
$jmeno=$zaznam["name"];
$atribut=$zaznam["required"];
$aktivni=$zaznam["active"];

if($aktivni == 1) { //Omezení jen na aktivní produkty
echo ("<td>" . $id_product . "</td><td>" . $jmeno . "</td><td>" . $kombinace . "</td><td>" . $reference . "</td><td>" . $quantity . "</td></tr>");
}
}
?>

      </tbody>
    </table>

 

radek.juthner

radek.juthner

@PrestashopUser03

Hi. Sorry. doesnt work. 

Can you repair my php code? Need to have product with no combination too.

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <meta name="robots" content="noindex,nofollow" />
    <title>Stav skladu</title>
  </head>

<strong>Skladové zásoby aktivních produktů</strong>

<?php
$pripoj = mysqli_connect('localhost', 'user', 'password','database');
mysqli_query($pripoj,"SET NAMES UTF8");


$dotaz = "SELECT\n"
	 . "    p.active,\n"
    . "    p.id_product,\n"
    . "    pa.reference,\n"
    . "    pa.upc,\n"
    . "    pa.price,\n"
    . "    pai.id_image,\n"
    . "    pl.name,\n"
    . "    GROUP_CONCAT(DISTINCT(pal.name) SEPARATOR \", \") as combination,\n"
    . "    pq.quantity\n"
    . "FROM ps_product p\n"
    . "LEFT JOIN ps_product_attribute pa ON (p.id_product = pa.id_product)\n"
    . "LEFT JOIN ps_stock_available pq ON (p.id_product = pq.id_product AND pa.id_product_attribute = pq.id_product_attribute)\n"
    . "LEFT JOIN ps_product_lang pl ON (p.id_product = pl.id_product)\n"
    . "LEFT JOIN ps_product_attribute_combination pac ON (pa.id_product_attribute = pac.id_product_attribute)\n"
    . "LEFT JOIN ps_attribute_lang pal ON (pac.id_attribute = pal.id_attribute)\n"
    . "LEFT JOIN ps_product_attribute_image pai on(pa.id_product_attribute = pai.id_product_attribute)\n"
    . "WHERE pl.id_lang = 3\n"
    . "AND pal.id_lang = 3\n"
    . "GROUP BY pa.reference\n"
    . "ORDER BY p.id_product, pac.id_attribute";  

$vysledek = mysqli_query($pripoj,$dotaz);
?>

<table style="width: 920px; height: 54px;" border="1">
      <tbody>
      <tr>
          <td>ID produktu
          </td>
          <td>Jméno produktu
          </td>
          <td>Varianta
          </td>
          <td>Kód produktu
          </td>
          <td>Množství
          </td>
        </tr>
        <tr>
<?php    
$counter = $counter + 1;
echo ($counter);
while ($zaznam = MySQLi_Fetch_Array($vysledek)){ 

$id_product=$zaznam["id_product"];
$reference=$zaznam["reference"];
$kombinace=$zaznam["combination"];
$quantity=$zaznam["quantity"];
$jmeno=$zaznam["name"];
$atribut=$zaznam["required"];
$aktivni=$zaznam["active"];

if($aktivni == 1) { //Omezení jen na aktivní produkty
echo ("<td>" . $id_product . "</td><td>" . $jmeno . "</td><td>" . $kombinace . "</td><td>" . $reference . "</td><td>" . $quantity . "</td></tr>");
}
}
?>

      </tbody>
    </table>

 

×
×
  • Create New...