Witam
czy ktoś już może coś takiego przygotowywał? może ma jakiś pomysł lub informacje które mogłyby mi pomóc?
w zasadzie to byłbym wdzięczny nawet za tutka jak wyświetlić wszystkie konfigurowalne produkty wraz z podrzędnymi prostymi.
z góry thx
try {
$i=$j=$k=$m=$n=$o=0;
$pdo = new PDO('mysql:host=---;dbname=---', '---', '---', array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
$pdo -> setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$table='<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td width="33%">Powiazania produktow</td><td width="33%">Produkty niepowiazane</td><td width="34%">Produkty niepowiazane</td></tr><tr valign="top"><td>';
$stmt_parent = $pdo -> query('SELECT DISTINCT products.`entity_id` as parent_id, products.`sku` as sku FROM `sklep_catalog_product_super_link` AS links, `sklep_catalog_product_entity` AS products WHERE links.`parent_id` = products.`entity_id` ORDER BY sku');
while($row_parent = $stmt_parent -> fetch())
{
$i++;
$table.='<strong>'.$row_parent['sku'].'</strong><br />';
$stmt_products_linked = $pdo -> query('SELECT products.`sku` as sku FROM `sklep_catalog_product_super_link` AS links, `sklep_catalog_product_entity` AS products WHERE links.`product_id` = products.`entity_id` AND links.`parent_id` = '.$row_parent['parent_id'].' ORDER BY sku');
while($row_products_linked = $stmt_products_linked -> fetch())
{
$table.=' '.$row_products_linked['sku'].'<br />';
$j++;
}
}
$stmt_parent -> closeCursor();
$stmt_products_linked -> closeCursor();
$table.='</td><td>';
$stmt_products_not_linked = $pdo -> query('SELECT products.`sku` as sku FROM `sklep_catalog_product_entity` AS products WHERE NOT EXISTS (SELECT links.`product_id` FROM `sklep_catalog_product_super_link` AS links WHERE products.`entity_id` = links.`parent_id` ) AND products.`type_id` <> "simple" ORDER BY sku');
while($row_products_not_linked = $stmt_products_not_linked -> fetch())
{
$table.='<strong>'.$row_products_not_linked['sku'].'</strong><br />';
$k++;
}
$stmt_products_not_linked -> closeCursor();
$table.='</td><td>';
$stmt_products_not_linked = $pdo -> query('SELECT products.`sku` as sku FROM `sklep_catalog_product_entity` AS products WHERE NOT EXISTS (SELECT links.`product_id` FROM `sklep_catalog_product_super_link` AS links WHERE products.`entity_id` = links.`product_id` ) AND products.`type_id` = "simple" ORDER BY sku');
while($row_products_not_linked = $stmt_products_not_linked -> fetch())
{
$table.=$row_products_not_linked['sku'].'<br />';
$m++;
}
$stmt_products_not_linked -> closeCursor();
$table.='</td></tr></table>';
$stmt_products_count = $pdo -> query('SELECT count(products.`entity_id`) as count FROM `sklep_catalog_product_entity` AS products WHERE products.`type_id` = "simple"');
while($row_products_count = $stmt_products_count -> fetch()) $n=$row_products_count['count'];
$stmt_products_count -> closeCursor();
$stmt_products_count = $pdo -> query('SELECT count(products.`entity_id`) as count FROM `sklep_catalog_product_entity` AS products');
while($row_products_count = $stmt_products_count -> fetch()) $o=$row_products_count['count'];
$stmt_products_count -> closeCursor();
echo '
Wszystkich produktow: '.$o.'<br />
Podstawowych produktow: '.$n.' ('.round(($n/$o)*100).'%)<br />
Grupowych produktow: '.($o-$n).' ('.round((($o-$n)/$o)*100).'%)<br />
Powiazanych grupowych: '.$i.' ('.round(($i/($o-$n))*100).'%)<br />
Powiazanych podstawowych: '.$j.' ('.round(($j/$n)*100).'%)<br />
Nie powiazanych grupowych: '.$k.' ('.round(($k/($o-$n))*100).'%)<br />
Nie powiazanych podstawowych: '.$m.' ('.round(($m/$n)*100).'%)<br />
<br />'.$table;
}
catch(PDOException $e) {
echo 'Połączenie nie mogło zostać utworzone: ' . $e->getMessage();
}