Magento 2

Magento FAQ: What are some common errors seen in Magento 2 carts?

Common errors encountered during the connection process and while sending the data from store to Unific # Connection Errors:

Error while retrieving integration metadata. Error message: ’java.lang.IllegalStateException: HMAC signing parameters are not present. Integration Id: ‘com.unific.models.integrations.Integration$Id@66fe2c83[organizationId=<organization-id>,integrationId=<integration-id>]‘’.

# If you get the above error while connecting your store to Unific,

  • Check that the access to resources is set to All
    Or,
    Select the 6 Custom Resources as shown in below image:

    unific -magento-resources

  • Check that the access token entered is correctly entered (check for whitespaces).

  • If moving from staging store to production make sure the connection details are of the production store.

  • Then reconnect the store after checking the above settings.


# Whitelist

  • Please submit a ticket at help.unific.com to get the list of IP addresses to whitelist

#  Logs on M2 server

Logs

Under the directory, <magento-root-directory>/public_html/var/logs/

There will be log files. The following are the log file names and example error messages that it holds. We should refer these log files if the webhooks are not being sent from the extension to Unific.

tail -f connector.log

2019-03-01T06:00:07+00:00 INFO (6): Cleaning cron job result : 0 records removed from automation . 0 records removed from importer . 0 records removed from campaign . Deleting archived folder result :

2019-04-01T05:00:07+00:00 INFO (6): Cleaning cron job result : 0 records removed from automation . 0 records removed from importer . 0 records removed from campaign . Deleting archived folder result :

 

tail -f exception.log

[2019-05-02 07:30:04] main.CRITICAL: Warning: Illegal string offset 'Content-Type' in /home/235270.cloudwaysapps.com/kvsknvchew/public_html/vendor/unific/connector/Connection/Rest/Connection.php on line 76 {"exception":"[object] (Exception(code: 0): Warning: Illegal string offset 'Content-Type' in /home/235270.cloudwaysapps.com/kvsknvchew/public_html/vendor/unific/connector/Connection/Rest/Connection.php on line 76 at /home/235270.cloudwaysapps.com/kvsknvchew/public_html/vendor/magento/framework/App/ErrorHandler.php:61)"} []


2. Cron Logs on M2 server

tail -f magento.cron.log

[PDOException]                                                                                                   

SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction

For the above error, we have to unlock the tables and empty the cron schedule table, with the following commands.

Following 2 commands need to be run on mysql server command prompt.

unlock tables;

truncate cron_schedule;

 

tail -f setup.cron.log

The directory 

Autoload error: Module 'Unific_Connector' from '/home/235270.cloudwaysapps.com/kvsknvchew/public_html/vendor/unific/connector' has been already defined in '/home/235270.cloudwaysapps.com/kvsknvchew/public_html/vendor/revenueconduitunific/connector'.ls

To fix this:
Remove unific connector from composer.json and after removing reinstalled the extension.


3. Unific Logs on M2 server

tail -f unific-audit.log

[2019-05-03 08:38:05] ConnectorLog.INFO: Message queued for sending: D67E1818-FD0F-4769-8F41-EEDFDF4C8A06 [] []

[2019-05-03 08:38:06] ConnectorLog.INFO: Message queued for sending: F09AB6E5-D9D2-4152-94C3-E54E01E36A02 [] []


4. Common logs on M2 server

tail -f update.log

[2019-05-02 11:30:02] update-cron.ERROR: Cron readiness check failure! Found non-writable paths: /home/store/public_html/bin/magento [] []

[2019-05-02 11:45:01] update-cron.ERROR: Cron readiness check failure! Found non-writable paths: /home/store/public_html/bin/magento [] []

5. Check caching on M2 Server

If the extension is updated or recent changes are not being reflected on the site or with extension,

check the opcache.validate_timestamps setting on the server.

opcache.validate_timestamps boolean

If enabled, OPcache will check for updated scripts every opcache.revalidate_freq seconds. When this directive is disabled, you must reset OPcache manually via opcache_reset(), opcache_invalidate() or by restarting the Web server for changes to the filesystem to take effect.

If this is set this to false, opcode cache needs to be manually flushed

If a client has the opcode caching setting for php-fpm to never expire it would always load old code which is cached until the cache is either manually flushed or php-fpm is restarted

6. Error while running composer update command

If you get an error like allow_url_fopen must be enabled in php.ini

and you have the ssh access (needs root) to their server,
You can check if the allow_url_fopen is On or Off (which obviously is Off as the above error) using below command:

php -i | grep allow_url_fopen

Check where the php is installed i.e. find the path to the php.ini file and search and enable the allow_url_fopen in the php.ini file
Before: 
allow_url_fopen = Off
After: 
allow_url_fopen = On

Again, using the php -i | grep allow_url_fopen command, confirm that the allow_url_fopen is now showing as On
And the continue with the composer update command

7. Authentication required (repo.magento.com):

While doing a composer update, if it prompts for the username and password for above URL, then you should provide the public key as the username and private key as the password.
This public and private key need to be generated from the developer's account.
Follow this procedure: https://devdocs.magento.com/guides/v2.3/install-gde/prereq/connect-auth.html

8. Site issues after the composer update - Unable to retrieve deployment version of static files from the file system:

After the composer update, if there are issues while loading the site, on the site frontend it will display
There has been an error processing your request: Request id: 1234567890
Now, this request-id is actually a log file which will have the actual error in it.
Path to that log file is <magento-root-directory>/var/report/1234567890.

If the log says: Unable to retrieve deployment version of static files from the file system
run the below command on the server:

bin/magento setup:upgrade && bin/magento setup:di:compile && bin/magento setup:static-content:deploy && bin/magento cache:clean

Reload the site and it should be working now.

9. Restarting the PHP-FPM service on M2 Server

Sometimes the extension changes are not immediately reflected even though the extension is updated.
I this case we need to restart the PHP FPM service.

If we have access to the server and client wants us to clean the cache, 
if it's a Linux server, you can do
    service php-fpm restart
or
    server php7.1-fpm restart
or
    service ea-php71-php-fpm restart
for non debian servers
    systemctl restart php-fpm

10. Only few webhooks are received and few are not

Check/Request the webhook message from the unific_Connector_message_queue table and check if the body of the message is a complete valid json.
If the webhook body is large, the body is only partially saved and the rest of the body is truncated.
In the logs the error is: Unific\Connector\Helper\Hmac::generateHmac() must be of the type array, null given

**This is for Unific Connector versions below 1.4.4**

The solution would be to change the field type of the "message" column of the table unific_Connector_message_queue from TEXT to MEDIUMTEXT

Need to run following MYSQL queries:

`ALTER TABLE unific_Connector_message_queue MODIFY message MEDIUMTEXT;`

After that run:
DELETE from unific_Connector_message_queue WHERE length(message) >= 65535;

 


M2 Admin Troubleshooting

1. Checking webhook logs on M2 Dashboard

On the Magento Admin Dashboard, we can see a Unific Extension (on the Left Side Bar) where we can see the logs for webhooks



If Unific connector log is missing in Magento Admin then client needs to add

bin/magento cron:install

2. Reauthorizing Unific Connector

If there are errors while generating the OAuth tokens, we can Reauthorize the Unific app.

In some cases, if the token generation failed and we see that only Consumer Key and Consumer Secret is generated (like below image), Reauthorize the Unific app.


Reauthorize - It will generate the Consumer Key, Consumer Secret, Access Token & Access Token Secret again.


The consumer isn't authorized to access Unific_Connector::config resources
If the store is running on PHP version 7.1.30, PHP version needs to be updated

https://community.magento.com/t5/Magento-2-x-Technical-Issues/REST-API-The-consumer-isn-t-authorized-to-access-resources-2-3-1/td-p/133545



If getting below error in the magento server logs:
Error: A field name was provided without a field value.
Check that the Unific Integration Id is filled in and is not empty.
Sometimes when releases are made to the server or if the extension is reinstalled this value get empty.
The solution is to Reconnect the store to Unific.

 


If Basic Auth Added:

If basic auth is added a testing site, we can generate the encrypted integration id and save that in Magento store if we have admin access.
Similarly, we can generate the bytes from the hmac secret and save that as the signing key to the Magento integration entry we have in Unific database  

 



To view the coupons created by Unific through API and that were used by the customers:

We can get a report from here:

Reports → Coupons (select the filters)

 

It will generate a report like below:


To view if the Unific Connector was successfully installed in store and is available as a module:
Log in to the store admin and go to:

For Magento version until 2.2.0:
     Stores > Configuration > Advanced > Advanced
     (this is taken away from the admin panel since Magento 2.2.0)

For Magento versions 2.3.x:

     System > Web Setup Wizard > Module Manager


This is how it looks: