Coluccini Posted August 26, 2014 Share Posted August 26, 2014 Hi, I've just noticed that after you save some changes on a Carrier at the backoffice, that Carrier ID change to the next auto increment ID. Is this suppose to happen or is this a bug? Can anyone help me on how can I avoid this from happening (I need the ID to be static so I can use it for a javascript reference). I'm using PS version 1.5.4.0. Thanks! Link to comment Share on other sites More sharing options...
Coluccini Posted August 26, 2014 Author Share Posted August 26, 2014 mhmmm I'm checking at the MySQL db and it appears that the problem it isn't that the ID it changing but it looks like every time I modify a Carrier it is save as a new one, and the previous one is deleted. I guess there is a logic behind this but I can't figure it out. Note: I have never changed anything at the BO. This is a default behavior Link to comment Share on other sites More sharing options...
Krystian Podemski Posted August 26, 2014 Share Posted August 26, 2014 This is not a bug, this is feature, let's assume that someone already place an order with Carrier ID 20 (shipping costs $20), you changed that price and what now? PrestaShop save this old carrier, disable it and create new one with new price, it's seems ok for me. Link to comment Share on other sites More sharing options...
donorsi Posted October 14, 2014 Share Posted October 14, 2014 This is not a bug, this is feature, let's assume that someone already place an order with Carrier ID 20 (shipping costs $20), you changed that price and what now? PrestaShop save this old carrier, disable it and create new one with new price, it's seems ok for me. That makes sense, but here is my situation. While i made changes and settings to the store, before is launched, i managed to have carrier IDs like 25 and 27, even though i just have 2 carriers. Is there a way to have that reset? It just looks better when they show as 1 and 2, at least before launch . I don't mind changing themself later.. Link to comment Share on other sites More sharing options...
v1c3nt Posted October 28, 2014 Share Posted October 28, 2014 (edited) Hello Coluccini I have the same problem and maybe a solution. In my case, i need a unique ID for the carrier (logical carrier in our company, not carrier in prestashop), the id_carrier from table prefix_carrier don't work (because it changes), and the name don't work (sometimes it changes for cosmetics reasons) So i will add a column carrier_code with strings like 'UPSXXX', 'CARRIER_Y' ... and override the duplication function to keep it in the new carrier. In my case this codes are usefull to exchange data to another website but you can create your own ids (numeric for example) I'm on the Prestashop 1.4 so i don't have code to give to you, hope that helps you Donorsi you can change it in the database manually (remove all other lines from prefix_carrier and edit the last two of them to change id) only if you don't have changed things in the others tabs (like price range). In that case you have to change references in other tables it's a lot of work to juste have nice ids. Edited October 28, 2014 by v1c3nt (see edit history) Link to comment Share on other sites More sharing options...
Eder Posted July 13, 2015 Share Posted July 13, 2015 Hello... I'm using prestashop with some modifications and had to made the same ID always. I don't need historic views, and there is no sense since you can't see it anywhere... Well, you can do a little trick, inverting the history logic. You'll keep the duplications logic and history, but will always use the same id. I do not recommend doing it because I don't know the consequences, so use it at your own risk. Using PS1.6.0.14, file controllers/admin/AdminCarrierWizardController.php, line 770. You can try something like this is any version: public function ajaxProcessFinishStep() { ... if (Validate::isLoadedObject($new_carrier)) { // inverting some logic to keep the same id always $aux = $new_carrier; $new_carrier = $current_carrier; $current_carrier = $aux; // Set flag deteled to true for historization $current_carrier->deleted = true; ... } The other and recommended way to keep track the way Prestashop does is using the hook "actionCarrierUpdate". Best, Eder. Link to comment Share on other sites More sharing options...
newcomer Posted November 1, 2016 Share Posted November 1, 2016 Hmm I noticed this as well. However in database ps_warehouse_carrier the Carrier ID doesn't get updated, it remained as it were the first ID assigned. Is this how it's supposed to work? Link to comment Share on other sites More sharing options...
meryy84 Posted December 30, 2016 Share Posted December 30, 2016 There are any new of this post? i'm using ps 1.6.1.6 and it's happening de same.. with any register update, the last one it's marked as deleted and a new register (id autoincremental) appear. There is a solution? Best regards, Maria 1 Link to comment Share on other sites More sharing options...
treyj45 Posted March 13, 2017 Share Posted March 13, 2017 (edited) I did this to 1.6.1.10 and it seems to be working with no historic carrier id data collected. controllers/admin/AdminCarrierWizardController.php starting at line 755 in the function ajaxProcessFinishStep if ($id_carrier = Tools::getValue('id_carrier')) { $carrier = new Carrier((int)$id_carrier); if (Validate::isLoadedObject($carrier)) { // Fill the carrier object with form data $this->copyFromPost($carrier, $this->table); $carrier->update(); $carrier->setTaxRulesGroup((int)Tools::getValue('id_tax_rules_group')); } } I also had to change the range code at line 665 if ($range_type == Carrier::SHIPPING_METHOD_WEIGHT) { if (!RangeWeight::rangeExist((int)$carrier->id, (float)$delimiter1, (float)$range_sup[$key])){ if(!RangeWeight::getRanges((int)$carrier->id)){ $range = new RangeWeight(); } else{ $range= new RangeWeight((int)$key); } } else { $range = new RangeWeight((int)$key); $add_range = false; } } if ($range_type == Carrier::SHIPPING_METHOD_PRICE) { if (!RangePrice::rangeExist((int)$carrier->id, (float)$delimiter1, (float)$range_sup[$key])) { if(!RangePrice::getRanges((int)$carrier->id)){ $range = new RangePrice(); } else{ $range= new RangePrice((int)$key); } } else { $range = new RangePrice((int)$key); $add_range = false; } } Edited March 16, 2017 by treyj45 (see edit history) 1 Link to comment Share on other sites More sharing options...
sadlyblue Posted November 15, 2018 Share Posted November 15, 2018 On 3/13/2017 at 10:32 PM, treyj45 said: I did this to 1.6.1.10 and it seems to be working with no historic carrier id data collected. controllers/admin/AdminCarrierWizardController.php starting at line 755 in the function ajaxProcessFinishStep I also had to change the range code at line 665 Thanks. In our new project we want to keep the carrier id. If anything changes we believe it should behave like the product and other objects. And you just saved me some time trying to solve the range issue. Link to comment Share on other sites More sharing options...
MaXi32 Posted July 22, 2020 Share Posted July 22, 2020 (edited) I guess the range of the ID has maximum of 2,147,483,647. That is 2 billions click to go. So, if somebody could reach that ID, it's the end of Prestashop life . ps: it's the same issue with prestashop 1.7.6.7 Edited July 22, 2020 by arafatx (see edit history) 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