Use old Quotes module

Introduction

After upgrading one instance of SugarCRM from version 7 to version 8 I wanted to use old Quotes module instead of the new one. Because a lot of modification on Quotes module I didn’t want to upgrade to a new one.

As you know Quotes module moved from BWC to Sidecar in version 7.9. So I created this post to help anyone who needs to do a similar thing with Quotes module. Or if you want to do it with some other module. This principle could be used.

How to…

You need to have a copy of old Quotes, so make a copy of this folders:

After upgrading to version 8 I replaced above folders with the old ones. But that is not enough, you need to tell SugarCRM that this module is BWC, not Sidecar. To do that create a new file and specify Quotes as BWC module. So, create the file in /sugar/custom/Extension/application/Ext/Include/modules.php and add code from the snippet below.

<?php
$bwcModules[] = 'Quotes';

If you don’t do the last step then all links to Quotes would be linked to Sidecar version instead of the BWC.

To use the old Quotes module just do Quick repair and rebuild. But when doing so many customizations I prefer to do the repair through a console. To do that navigate in your console to sugar folder of your project and execute the following command.

/Applications/MAMP/bin/php/php7.12/bin/php -f repair.php

Note that I am using Mac, on other OS it can be different. Also, I am using PHP version 7.12. I prefer this because I would see immediately results and all errors in the console.

Corrections

Depending on your customization it is possible that you would get more errors or bugs when trying to use old Quotes module or any other.

Database

First that I got was an error on the database key in the Quotes table.

In /sugar/modules/Quotes/vardefs.php ‘quote_num’ field had a unique index that couldn’t be applied to the new database. Previously it was ‘fields’ => array(‘quote_num’, ‘system_id’) but now we have only quote_num as unique index.

So you can change it directly here because after all modifications this module is not upgrade safe anymore.

Reports

As Reports module was also changed to Sidecar we need to change the links to it in Quotes code. In this case, I wanted to use new Reports too, so this was fine for me. Link can be changed directly in Quotes module /sugar/modules/Quotes/clients/base/menus/header/header.php but I have already customized menu so I changed it in custom directory /sugar/custom/modules/Quotes/clients/base/menus/header/header.php

Note that the last approach is better, it is always preferred to do changes in the custom folder not at the actual module.

As you can see the link is set to Sidecar, previous was ‘route’=>’#bwc/index.php?module=Reports&action=index&view=quotes&query=true&report_module=Quotes’

Layout

For some modules, the layout can be a problem. I didn’t have problems on Quotes layout but after upgrading from SugarCRM 7 to SugarCRM 8 I had problems with the layout of Leads, Cases etc. Problem is easy to solve. In SugarCRM 8 layout has been changed and if you make customization of it then it would probably break. Custom layout for record view is defined in the file /sugar/custom/modules/{MODULE_NAME}/clients/base/layouts/record/record.php similar is for list view. Just copy default record.php layout to it and add your modifications. Here is an example of a default record.php layout in SugarCRM 8.

Other

I didn’t have much more problems. But there were some bugs in modified PHP files mostly related to the new PHP version. For that just take a look at your PHP error log file and sugarcrm.log

Conclusion

This was an example of how to use old Quotes module. This can be applied to any BWC module that you want to use instead Sidecar. Just note that you need to know which modules are related so maybe you will need to change more than one module if it not working properly. I luckily didn’t had that kind of problems with Quote module.

If you liked this post, check other our posts too. For instance our post here about extending module class.