Jump to content
Fidlimidly

Řazení zboží v kategorii dle označení "Výprodej" (on sale !) troufá někdo?

Recommended Posts

<?php$id_category = 111; // Write your category id.$db_user = "user"; // Write your DB user.$db_password = "password"; // Write your DB password.$db_name = "name"; // Write your DB name.$db_host = "localhost"; // Write your DB host.$connection = mysql_connect($db_host, $db_user, $db_password);$on_sale = 1;$position = 0;while ($on_sale >= 0) { $sub_query = "SELECT id_product FROM product WHERE on_sale = ".$on_sale; $query_products = "SELECT id_product FROM category_product WHERE id_category = ".$id_category." AND id_product IN ( ".$sub_query." )"; $result_products = mysql_db_query($db_name, $query_products, $connection); while ( $row = mysql_fetch_array($result_products) ) {  $query = "UPDATE category_product SET position = ".$position;  $query .= " WHERE id_product = ".$row['id_product']." AND id_category = ".$id_category;  mysql_db_query($db_name, $query, $connection);  $position = $position + 1; } $on_sale = $on_sale - 1;}mysql_close($connection);?>

 

Edited by Peter Liska (see edit history)

Share this post


Link to post
Share on other sites

Takže přepsat soubor "theme/product-sort.tpl " ? / add the code to theme/product-sort.tpl what is above?

Share this post


Link to post
Share on other sites

To je nezávislý PHP program, který pracuje jen s tvou DB. Seřadí zboží (tabulka - category_product) ve vybrané kategorii dle hodnoty on_sale v tabulce product.

 

Produkty s on_sale = 1 budou první.

Edited by Peter Liska (see edit history)

Share this post


Link to post
Share on other sites

Takže vytvořím v BO tabulku nebo vytvořím php soubor category_product.php v www/admin/tabs ? promiň ale takové úpravy jsem ještě nedělal...můžeš napsat v zkratce postup ?

Share this post


Link to post
Share on other sites

Takže vytvořím v BO tabulku nebo vytvořím php soubor category_product.php v www/admin/tabs ? promiň ale takové úpravy jsem ještě nedělal...můžeš napsat v zkratce postup ?

 

Psal jsem o tabulkách PrestaShop v tvé DB, kde máš uloženy všechny údaje.

 

Pokud neovládáš ani základy PHP a MySQL, tak na to asi raději zapomeň.

 

Nebo si najmi někoho kdo ti udělá krabicové řešení.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More