Jump to content
Jupiterr

Automatically changing the default combination when out of stock

Recommended Posts

Hello,

 

I'm having a problem with the combinations. The case is the following:

 

1. Add a product with 2 combinations and stock.

2. Sell all the stock from the first combination.

3. The product says "This product is no longer in stock with those attributes but is available with others."

4. Change to the other combination/make it default an the message is gone.

 

The question here is:

Is it possible to auto-switch the default combination to another one so the user doesn't see this message and always the products are "available"?

 

I'm using Prestashop 1.6.0.9.

 

Thanks in advance!

  • Like 2

Share this post


Link to post
Share on other sites

You must change SQL query in core of your prestashop.

 

Need to make custom sql table with id of product and make some PHP development.

Share this post


Link to post
Share on other sites

Hello,

 

I have the same problem!

 

I was curious if someone has a clear description of the solution?

 

Thanks in advance!!

Share this post


Link to post
Share on other sites

Hi!

I've created this module for PS 1.6

When user confirm order:

- auto-switch the default combination to another one if quantity of  combination is great then 0.

- module have option to deactivate product from store if product dont have any other combination with quantity great then 0.

 

For more info send PM

 

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Salut!

Am creeat acest modul pentru PS 1.6

Cand un user confirma comanda:

- schimba automat atributul/combinatia de atribute default cu un altul in care cantitatea este mai mare decat 0

- are optiunea de a dezactiva produsul daca acesta nu mai are atribute/combinatii de atribute cu cantitate mai mare decat 0

 

Pentru alte detalii dati-mi un mesaj in PM.

 

attribute_auto_switch.jpg

Share this post


Link to post
Share on other sites

Since this is a feature that should have been implemented in the PS core functionalities and for over 2 years NO solutions were given except 2 paid modules, I am going to SPAM all the threads that address this matter.
I am sorry but it doesn't seem fair at all that such an important base feature is made available via paid module when it should have been rolled out in a PS update long time ago  :( 
 

I've seen so many PS stores losing customers because they see an Out of Stock message on a product that actually HAS stock on other combinations. It's already beyond ridiculous, this silence of the PS staff.
 

This a call of desperation to the PS staff, of a lot of PS users, not just mine.

Let the solution reveal itself at last!

#MegaBump

  • Like 3

Share this post


Link to post
Share on other sites

You can use a cron job to reset it, this is how i do it

 


$sql = 'SELECT * FROM `'._DB_PREFIX_.'product_attribute`    GROUP by id_product';
$results = Db::getInstance(_PS_USE_SQL_SLAVE_)->executes($sql);

if($results)
{
    foreach($results as $res)
    {

        $sql = 'SELECT * FROM `'._DB_PREFIX_.'product_attribute`   WHERE   quantity > 0 AND id_product = '.(int)$res['id_product'];
        $new_res = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);    

        if($new_res)
        {
            Db::getInstance(_PS_USE_SQL_SLAVE_)->execute('UPDATE `'._DB_PREFIX_.'product_attribute_shop` SET default_on = 1 WHERE id_product_attribute = '.(int)$new_res['id_product_attribute']);
            Db::getInstance(_PS_USE_SQL_SLAVE_)->execute('UPDATE `'._DB_PREFIX_.'product_attribute` SET default_on = 1 WHERE id_product_attribute = '.(int)$new_res['id_product_attribute']);

            Db::getInstance(_PS_USE_SQL_SLAVE_)->execute('UPDATE `'._DB_PREFIX_.'product_attribute_shop` SET default_on = NULL WHERE id_product_attribute = '.(int)$res['id_product_attribute']);
            Db::getInstance(_PS_USE_SQL_SLAVE_)->execute('UPDATE `'._DB_PREFIX_.'product_attribute` SET default_on = NULL WHERE id_product_attribute = '.(int)$res['id_product_attribute']);
        }
    }

}

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

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