Wednesday, February 5, 2020

Magento bccomp Error

[Fri Jan 17 11:51:13.302280 2020] [php7:error] [pid 2430] [client 172.17.0.1:44334] PHP Fatal error:  Uncaught Error: Call to undefined function Magento\\InventorySales\\Model\\IsProductSalableForRequestedQtyCondition\\bccomp() in vendor/magento/module-inventory-sales/Model/IsProductSalableForRequestedQtyCondition/IsSalableWithReservationsCondition.php

Solution :

Install php bcmath package and restart apache.
sudo apt-get install php-bcmath
The solution is for apache installed on Ubuntu. If you have installed php using different command like sudo apt-get install php7.0 or sudo apt-get install php7.2 or sudo apt-get install php5.6, you need to install the package using similar method i.e. sudo apt-get install php7.0-bcmath or sudo apt-get install php7.2-bcmath or sudo apt-get install php5.6-bcmath etc.

Mongodb - Import JS file

Importing database file in mongdb can be a headache if you haven't done it before. The most common way of exporting and importing database using commands mongodump and mongorestore. But what if you have js file to import.
Here is the way to import js file in mongo database.

Solution :

mongo 127.0.0.1/dbname exportedjsfilename.js

Mongo DB Error

MongoDB Exception – yii\mongodb\Exception
127.0.0.1:27017: The 'cursor' option is required, except for aggregate with the explain argument


Solution :

Check the version of mongo db. I got this error while importing a database into mongodb 4.0 and database was exported from older version of mongo db 2.6 or 3.2.

I installed mongodb 2.6 in docker and imported the database. Now application was connected from docker mongodb.

It fixed the issue.