hatak Posted August 28, 2015 Share Posted August 28, 2015 I'm trying to change my running shop with plenty of products with stock quantities to multistore. I wonder is there a way to change option: "share available quantities" in existing default group to yes without resetting quantities to 0? Has someone accomplished this in a reasonable way? Link to comment Share on other sites More sharing options...
hatak Posted August 28, 2015 Author Share Posted August 28, 2015 so that option is only for new shops - it's ridiculous Link to comment Share on other sites More sharing options...
hatak Posted September 26, 2015 Author Share Posted September 26, 2015 I found the solution. And it also prevents to issue: "You already have the maximum quantity available for this product." when multistore is ON , "allow order when out of stock" is ON (there are dozens topics with this issue without answer ) I've changed that stupid reset function in classes/stock/StockAvailable.php to: public static function resetProductFromStockAvailableByShopGroup(ShopGroup $shop_group) { if ($shop_group->share_stock) { $shop_list = Shop::getShops(false, $shop_group->id, true); if (count($shop_list) > 0) { $id_shops_list = implode(', ', $shop_list); return Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'stock_available SET id_shop=0,id_shop_group=1 WHERE id_shop_group=0'); } } else { return Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'stock_available SET id_shop=0,id_shop_group=1 WHERE id_shop_group=0'); } } it's working with PS 1.6 3 Link to comment Share on other sites More sharing options...
jalokin80 Posted November 14, 2015 Share Posted November 14, 2015 Thanks for the hack, hatak. It works like a charm Link to comment Share on other sites More sharing options...
AkkaNumi Posted December 18, 2015 Share Posted December 18, 2015 Thanks Hatak. You save me few hours of work It works for me in version 1.5.3.1 I don't know why presta have to reset all stock. Any idea? Maybe problems will show after this fix 1 Link to comment Share on other sites More sharing options...
hannes01 Posted January 7, 2016 Share Posted January 7, 2016 (edited) Hi, thanks for the solution. Can I ask a question about it? Here's my issue: 1. I had a working shop (Shop A) and a few months ago I hired a developer to set up a multishop (to create Shop B ) 2. I thought that Shop A stock quantities automatically apply to Shop B as well. I just found out that its not true. 3. Now I have different quantites in Shop A and Shop B. 4. Right now Shop A has the correct quantities. If I apply this code, is it possible to make sure that Shop B will get the quantities of Shop A? Thanks! PS. Advanced Stock Management has been disabled for the whole time. Edited January 15, 2016 by hannes01 (see edit history) Link to comment Share on other sites More sharing options...
hatak Posted January 15, 2016 Author Share Posted January 15, 2016 if option: share stocks is disabled - the point of creating particular multishop (in your case is the point when stocks will be "live with its own life" Link to comment Share on other sites More sharing options...
doigro Posted May 5, 2016 Share Posted May 5, 2016 I can not add products to the cart after sharing quantities in 1.615 Link to comment Share on other sites More sharing options...
YiannisK Posted June 28, 2016 Share Posted June 28, 2016 I can not add products to the cart after sharing quantities in 1.615 I want to enable quantity sharing with this hack not to loose quantities, but I'm afraid that it will create other problems. Have you found a solution? Link to comment Share on other sites More sharing options...
El Patron Posted July 1, 2016 Share Posted July 1, 2016 If anyone just wants additional domain (stores) that share 'everything' but has configuration for localization of stand alone shop, check this module out. https://www.prestashop.com/forums/topic/530535-module-international-seo-multishop-pro/ I ran into many issues with multitshop, but not with native so much but in non-compliant themes/modules, this partly due to PS not have a 'multishop' compliant feature on addon's. I still think native ps multitshop is very good when used correctly to duplicated same content across domains...but myself and clients wanted another solution, this was first written for 1.4. but back by popular demand. Link to comment Share on other sites More sharing options...
Mat_D1245 Posted November 4, 2016 Share Posted November 4, 2016 I found the solution. And it also prevents to issue: "You already have the maximum quantity available for this product." when multistore is ON , "allow order when out of stock" is ON (there are dozens topics with this issue without answer ) I've changed that stupid reset function in classes/stock/StockAvailable.php to: public static function resetProductFromStockAvailableByShopGroup(ShopGroup $shop_group) { if ($shop_group->share_stock) { $shop_list = Shop::getShops(false, $shop_group->id, true); if (count($shop_list) > 0) { $id_shops_list = implode(', ', $shop_list); return Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'stock_available SET id_shop=0,id_shop_group=1 WHERE id_shop_group=0'); } } else { return Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'stock_available SET id_shop=0,id_shop_group=1 WHERE id_shop_group=0'); } } it's working with PS 1.6 I'm really interested in that hack! It's just what I was looking for. But trying to figure out the function you wrote, i guess I have to fit the id_shop and the id_shop_group variables... And moreover, I don't get the point of that "if" condition, since you return the the same whatever... Can you (or whoever) please clarify that point? I'd be really thankful for any infos to fix that stupid reset function built by Presta ! 1 Link to comment Share on other sites More sharing options...
Mat_D1245 Posted November 11, 2016 Share Posted November 11, 2016 Sooo, me again... I found that: http://blog.irrelevant.com/2013/08/prestashop-switching-to-shared-stock.html Is it really that simple?? I mean, when I code something, there is always a purpose behind a function, otherwise I wouldn't spend time on it. And I'm not a pro-team of international coders like Prestashop has. But I really don't get the point of that reset function if it is that simple to switch from shared to not shared. I guess undoing would be more problematic, though IMHO a simple droplist for the choice of who's keeping the children or do we share them half/half wouldn't be that hard to implement... But as said, I'm more of a designer with coding abilities than a presta core developer. Anyway, before I commit, I'd like to hear of any problem I might run in doing it. Thanks in advance! Link to comment Share on other sites More sharing options...
Mat_D1245 Posted November 11, 2016 Share Posted November 11, 2016 Another solution for multiple groups of shops would be to modify hatak's hack, to get a function like so: public static function resetProductFromStockAvailableByShopGroup(ShopGroup $shop_group) { if ($shop_group->share_stock) { $shop_list = Shop::getShops(false, $shop_group->id, true); if (count($shop_list) > 0) { $id_shops_list = implode(', ', $shop_list); return Db::getInstance()->execute(' UPDATE '._DB_PREFIX_.'stock_available SET id_shop=0, id_shop_group='.$shop_group->id.' WHERE id_shop IN ('.$id_shops_list.')' ); } } else { return Db::getInstance()->execute(' DELETE FROM '._DB_PREFIX_.'stock_available WHERE id_shop_group = '.$shop_group->id ); } } I didn't test it yet, but theoretically, it should work without having to do any sql request, and moreover it should take in count the shops and groups of shops we are actually concerned about (for those who have several groups). Link to comment Share on other sites More sharing options...
01generator Posted January 20, 2017 Share Posted January 20, 2017 Well I came up with another solution. You are making all the changes in the database. 3 to 4 queries are needed. First of you change the value in ps_shop_group from 0 to 1 in share_stock column. Then you run the following simple queries. UPDATE ps_stock_available SET id_shop_group = 1; #assuming your id_shop_group is 1 DELETE ps_stock_available WHERE id_shop = 2; #my default shop is id 1 and i want the quantities from shop 1 UPDATE ps_stock_available SET id_shop = 0; #thats the final trick! I have not tested this very far but so far I did not face any issues. Back Up you database always Eneble maintenace mode before changes Re back up database just to be sure HINT: After you issue the last query go to your dumb sql file and retrieve all the insert queries for ps_stock_available and run them in your DB. If you do that you will be able to return to these values if you disable share stock option in multistore. Furtheremore I strongly believe that these values are needed. 1 1 Link to comment Share on other sites More sharing options...
Zitty Posted March 31, 2017 Share Posted March 31, 2017 Well I came up with another solution. You are making all the changes in the database. 3 to 4 queries are needed. First of you change the value in ps_shop_group from 0 to 1 in share_stock column. Then you run the following simple queries. UPDATE ps_stock_available SET id_shop_group = 1; #assuming your id_shop_group is 1 DELETE ps_stock_available WHERE id_shop = 2; #my default shop is id 1 and i want the quantities from shop 1 UPDATE ps_stock_available SET id_shop = 0; #thats the final trick! I have not tested this very far but so far I did not face any issues. Back Up you database always Eneble maintenace mode before changes Re back up database just to be sure HINT: After you issue the last query go to your dumb sql file and retrieve all the insert queries for ps_stock_available and run them in your DB. If you do that you will be able to return to these values if you disable share stock option in multistore. Furtheremore I strongly believe that these values are needed. Thanks! it works Link to comment Share on other sites More sharing options...
Prestafan1234 Posted July 5, 2017 Share Posted July 5, 2017 Well I came up with another solution. You are making all the changes in the database. 3 to 4 queries are needed. First of you change the value in ps_shop_group from 0 to 1 in share_stock column. Then you run the following simple queries. UPDATE ps_stock_available SET id_shop_group = 1; #assuming your id_shop_group is 1 DELETE ps_stock_available WHERE id_shop = 2; #my default shop is id 1 and i want the quantities from shop 1 UPDATE ps_stock_available SET id_shop = 0; #thats the final trick! I have not tested this very far but so far I did not face any issues. Back Up you database always Eneble maintenace mode before changes Re back up database just to be sure HINT: After you issue the last query go to your dumb sql file and retrieve all the insert queries for ps_stock_available and run them in your DB. If you do that you will be able to return to these values if you disable share stock option in multistore. Furtheremore I strongly believe that these values are needed. Thanks for this solution. It has been driving me crazy that stock is not working when you make a multistore in an existing shop. However, you are missing something in query #2. It should be: DELETE FROM ps_stock_available WHERE id_shop = 2; without FROM the syntax is invalid. 2 Link to comment Share on other sites More sharing options...
Un_Tal_Iban Posted August 15, 2018 Share Posted August 15, 2018 On 20/1/2017 at 11:10 AM, 01generator said: Well I came up with another solution. You are making all the changes in the database. 3 to 4 queries are needed. First of you change the value in ps_shop_group from 0 to 1 in share_stock column. Then you run the following simple queries. UPDATE ps_stock_available SET id_shop_group = 1; #assuming your id_shop_group is 1 DELETE ps_stock_available WHERE id_shop = 2; #my default shop is id 1 and i want the quantities from shop 1 UPDATE ps_stock_available SET id_shop = 0; #thats the final trick! I have not tested this very far but so far I did not face any issues. Back Up you database always Eneble maintenace mode before changes Re back up database just to be sure HINT: After you issue the last query go to your dumb sql file and retrieve all the insert queries for ps_stock_available and run them in your DB. If you do that you will be able to return to these values if you disable share stock option in multistore. Furtheremore I strongly believe that these values are needed. Works perfect with prestashop 1.7.4.2 Link to comment Share on other sites More sharing options...
hardstonepaul Posted November 4, 2018 Share Posted November 4, 2018 (edited) Hello i have Prestashop 1.7.4.3 I started with Two Shop groups but no working after thinking i decide work only whit One Group, i make some changes on the DB: Delete the group_shop (In this case) 2 Put all shops on the default group, on group 1 Go to stock_available and set the column id_chop all in 0 (teke care that you no have repeat product with different id_shop) Really i don't know why (if some one can explain) but work for me. Regards Edited November 4, 2018 by hardstonepaul (see edit history) Link to comment Share on other sites More sharing options...
pijucat Posted February 23, 2019 Share Posted February 23, 2019 Dear all I am suffering the same issue, and these solution does not works for me with the PS 1.7.5. After define the DDBB values from the table, the stock of main web is removed. I checked several times but I can not do it with the properly way. I have a default grup with the option Do Not Share Quantites(Share quantities disabled) defined. From this group, there are 5 stores, but I only want the main store(main.com/admin..) that contains the stock properly imported from a migration. Then, the rest 4 stores can be removed, but I can not do it on Backoffice because these stores contains orders imported. Then, I would like to remove the four stores mantaining the main with the good stock, and then, change the Grup option in order to be able to share quantities into the store group, and create the rest of stores later sharing stocks. Can you help me? Thank you in advance. Joan Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now