Before we get started, lets make sure you are on the correct guide.
If your store is on Magento 2 or above, then you are on the correct page. Read on!

Overall process for setting up Magento 2

  1. Install the Magento 2 Extension 
  2. Authenticate Magento 2 with Unific OAUTH 
  3. Confirm that the integration works
  4. What to do if you have multiple environments.
  5. Troubleshooting


Let's get started!

--------------------------------------------------------------------------------------------------------

Install the Magento 2 Extension

There are two options to install the extension. You only need to follow ONE of options:

  1.  Install using Composer
    OR
  2. Install manually with the source code (only for really advanced users)

Install using Composer

Do this option only if you are a developer, or send it to your developers:

  1. SSH to your sever: ssh <user>@<ip-addresss-of-server>
  2. Go to the public_html directory of the store
  3. Open composer.json and add below section under repositories:
  4. Visit https://magento2connector.unific.com
  5. as the above link says, copy paste the JSON snippet in composer.json

    "repositories": [{
        "type": "composer",
        "url": "https://magento2connector.unific.com"
      }],
  6. Save composer.json file 
  7. Next, we need to update composer so that the new changes are picked up by Magento.
    Run this command:

    composer update
  8. Then we need to tell composer which version to require. The command below will require any version greater than 1.4 of the Unific Connector:

    composer require "unific/connector:^1.4.0"
  9. Now we need to run these two commands to upgrade Magento database schema, and also to clear the cache

    bin/magento setup:upgrade
    bin/magento cache:clean
  10. Finally, we need to install cron support for Magento 2. This is required because Unific Connector sends Webhooks in an asynchronous fashion to control the load on Magento 2 installation. The following command will install cron for the www-data user.

    sudo -u www-data bin/magento cron:install

Install manually using the source code

Sometimes store administrators are not allowed to install extensions from Composer OR the Magento Marketplace. In that case we also offer the option to install from the source code. This is not recommended for the novice user! 

  1. Navigate to: https://magento2connector.unific.com/
  2. On that page, in the "Release" section click the link with the largest release number.
  3. That will trigger a download. Save that to a location on your computer that you can find. the file name will start with "unific-connector" and end with ".tar"
  4. Upload this file to the server where Magento 2 store is hosted
  5. Then navigate to the root folder of your Magento 2 store installation 
  6. Change the  "/path/to/connector.tar" portion of the command below to where the tar file was uploaded on that server. Then run the command:

    mkdir -p app/code/Unific/Connector && tar -xvf /path/to/connector.tar /app/code/Unific/Connector

If you are having trouble with installation, please contact us at support@unific.com.
--------------------------------------------------------------------------------------------------------

Authenticate Magento 2 with Unific OAUTH 

All done with the installation? Great! If not, please contact support@unific.com.

The next step is to sign up for a Unific account. 

  1. Go to https://app.unific.com/ 
  2. Enter the credentials you want
  3. Fill in the Company Information step 
  4. Next, select Magento 2 as your shopping cart 

5. A pop up will appear. If it doesn't appear you might have a popup blocker. Please disable it for app.unific.com.

6. You should already have the Unific extension installed if you are following this guide. If you don't, scroll to the top of this page to see the instructions.

7. Click "Continue" if you already have the Unific extension installed.
8. Next you will see this page where you need to enter certain details.

9. We will have to look inside of Magento 2 admin to find the details this page asks for.

(if you are installing Unific on a non-production environment for testing, see the "What to do if you have multiple environments" section below.)

8.  Where to find these details:

Enter the Magento 2 store's URL: This is the production URL of your Magento 2 instance. Use the URL you send to your customers.

The details below are in the Magento 2 admin:

Consumer Key
Consumer Secret
Access Token 

Here's how to find them:
  a. Log in to the Magento Admin
  b. Click on "System" in the main menu
  c. Click "Integrations" on the "System" menu
  d. Click the pencil icon next to the "Unific-Integration" row
  e. Here you'll find the details you are looking for at the bottom inside of Magento 2 

9. Enter the details from Magento and click "Connect"

10. If everything worked well, you should see a "Success" message.

*** If you have multiple environments, you will need to repeat this process for ALL environments ***  

11. Continue with the Unific signup process to connect HubSpot (follow the prompts). 

--------------------------------------------------------------------------------------------------------

Confirm that the integration works 

The easiest way to confirm that there is a valid connection between Magento 2 and HubSpot is to open up your online store and register a new account. 

Unific's extension will send a webhook to Unific and Unific will sync it to HubSpot in a few minutes.

If this is not working, then it may be that Unific is not getting webhooks from Magento 2.

Please contact support@unific.com for additional help.

--------------------------------------------------------------------------------------------------------

What to do if you have multiple environments

It is often the case that there are multiple environments like Dev, QA, Staging, and Production for Magento 2 stores. 

If you would like to test Unific on environments other than production you may add multiple stores within a single Unific account and connect them to a single HubSpot portal.

If you do have multiple environments, you must install the extension on all environments that you want to test and go through the "Authenticate Magento 2 with Unific OAUTH " process above.

--------------------------------------------------------------------------------------------------------

Troubleshooting

1.Whitelist

Check if you have whitelisted Unific's IP Addresses. If you require whitelisting, please contact support@unific.com and we'll send you our IP Addresses to whitelist.

2. Unific's Logging

Unific's log files are put under the directory:

<magento-root-directory>/public_html/var/logs/

Refer to these log files if the webhooks are not being sent from the extension to Unific.

connector.log - If there are issues during installation, they should be logged here
unific-audit.log - shows the webhooks that are queued up for sending to Unific


3. Problems and Solutions

A. Problem: this error appears in magento.cron.log

[PDOException]                                                                                          

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

Solution: In your MySQL command line, unlock the tables and empty the cron schedule table, with following commands:

> unlock tables;
> truncate cron_schedule;

-------
B. Problem:
this error appears in setup.cron.log

Autoload error: Module 'Unific_Connector' from '<magento-root-directory>/public_html/vendor/unific/connector' has been already defined in '<magento-root-directory>/public_html/vendor/unific/connector'

Solution: 

  1. Remove unific connector from composer.json
  2. Reinstall the Unific Connector extension

-------
C. Problem: 

Unific Connector extension is updated, but recent changes are not reflected in the Magento 2 Admin on the extension pages.

Solution: Check the opcache.validate_timestamps setting in the PHP configuration of 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.

  1. If this is set this to false, opcode cache needs to be manually flushed
  2. If the opcode caching setting for php-fpm is set to never expire it will always load old code which is cached until the cache is either manually flushed or php-fpm is restarted 

-------
D. Problem:
If extension changes are still not immediately reflected after the extension is updated.



Solution:
Restart PHP-FPM (if your site uses PHP-FPM)

service php-fpm restart

This command might differ based on your operating system

-------
E. Problem: 

Error while running composer update:

allow_url_fopen must be enabled in php.ini


Solution:

Check if the allow_url_fopen is On or Off using this command on the server (as root user):

php -i | grep allow_url_fopen

If it's 'Off' change allow_url_fopen setting in php.ini file that's being loaded to 'On'.
So it should look like this in php.ini:

allow_url_fopen = On

-------
F. Problem

Site issues after running composer update:

There has been an error processing your request: Request id: 1234567890

This request id is actually a log file which will have the actual error in it. That log file will be located in:

<magento-root-directory>/var/report/1234567890

If you open that file, it might say:

Unable to retrieve deployment version of static files from the file system:


Solution:
Run this command on the Magento 2 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 work again.

-------
G. Problem

If you are on an older version of the Unific Connector you may get the error below while running 'composer update':

Repository not found

In this case, you will need to update your composer.json contents to match what is shown in the "Install using Composer" section above. 

After making that change, run these commands to remove the older version of the extension and install the newest version.

composer remove unific/connector
composer update --lock
composer require "unific/connector:^1.4.0"
composer update --lock

Did this answer your question?