Jump to content

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
Link to comment
Share on other sites

  • 1 month later...
  • 4 weeks later...
  • 1 year later...

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

Link to comment
Share on other sites

  • 4 months later...

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
Link to comment
Share on other sites

  • 2 years later...

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']);
        }
    }

}

 

Link to comment
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...