UPS is one of the most recognized names in the shipping industry. They are also a very common choice when shipping products to your customers. PrestaShop has modules for UPS so that you can use them for your shipping needs. There seems to be an issue in the free UPS module (upscarrier, aka Connect to UPS) when configuring the module. The products are not always being listed in the Product Settings tab when configuring the modules. This article explains the issue and how to fix it for your PrestaShop store.
- The steps below are specifically presented for those with cPanel based webservers. As long as you can access your file structure, however, you can implement the actual fix.
- This fix works for both PrestaShop 1.5.x and 1.6.x versions.
What is the exact error?
The drop-down menu in the Product Settings tab of the UPS module is supposed display products, but it is empty.
What is causing the error?
The error is caused by an SQL SELECT statement where the products are supposed to be pulled from the database to populate the dropdown. It actually finds the number of products and sets as many blank rows, so the data is coming back as NULL. When checking, we noticed that the limiting factor is the id_lang column setting. It is currently set to ‘2‘.
The test installation had only the default language of “English“. This is represented in the code by the variable “lang_id“. If only one language is loaded, then then “lang_id” would be equal to “1“. Replacing the hard set code of ‘2‘ with the dynamic code $this->context->language allows the proper language id to be used. This allows the dropdown to populate with the products.
How to fix the missing products in the UPS product settings
- Log into your cPanel interface.
- Use the cPanel File Manager and navigate to your modules/upscarrier folder.
- Locate the upscarrier.php file and open it for editing.It is highly recommended you make a copy of the file before making any changes
- Once inside, locate the line of code below. It should be line 1180.LEFT JOIN `’._DB_PREFIX_.’product_lang` pl ON (pl.`id_product` = p.`id_product` AND pl.`id_lang` = 2′.(version_compare(_PS_VERSION_, ‘1.5.0’) >= 0 ? ‘ ‘.$this->context->shop->addSqlRestrictionOnLang(‘pl’) : ”).’)
- Replace the entire line of code with the following line:LEFT JOIN `’._DB_PREFIX_.’product_lang` pl ON (pl.`id_product` = p.`id_product` AND pl.`id_lang` = ‘.$this->context->language->id.(version_compare(_PS_VERSION_, ‘1.5.0’) >= 0 ? ‘ ‘.$this->context->shop->addSqlRestrictionOnLang(‘pl’) : ”).’)
- Once you have replaced the line of code, click on the Save Changes button in the upper right corner to save it.
Now you can visit your ‘Connect to UPS‘ module and view the Product Settings tab; the products will display in the dropdown properly.