(#67) How to Set Up Access to Magento on a Local Network for Odoo Integration

(#67) How to Set Up Access to Magento on a Local Network for Odoo Integration

When integrating Odoo with Magento, particularly within a local network, connectivity issues can arise that may disrupt API testing and data synchronization. Ensuring seamless access between Odoo and Magento is critical for a successful integration. This guide outlines the steps to configure access from the Odoo server to a Magento installation hosted on a separate Ubuntu system within the same network. By following these steps, you can establish a connection between the Odoo and Magento servers, enabling smooth API testing and effective collaboration between the two applications.

Step 1: Find the Local IP Address of the Magento System

First, identify the IP address of the machine running Magento:

1. On the system running Magento, open a terminal and enter:

? ?ip a        

2. Locate the IPv4 Address for the active network connection, which will look like 192.168.1.10

Step 2: Update Magento’s Base URL to Allow IP-Based Access

Magento is typically configured to allow access only from localhost, so we need to update the Base URL to accept connections from the IP address.

Update Base URL in Magento Admin Panel

1. Log in to the Magento Admin Panel.

2. Navigate to Stores > Configuration > General > Web.

3. Under Base URLs and Base URLs (Secure), update the URLs to use Magento’s IP address:

? ?- For example: https://192.168.1.10/ for unsecure and https://192.168.1.10/ for secure URLs.

4. Save changes and flush the Magento cache:

? ?- Go to System > Cache Management and click Flush Magento Cache.

Update Base URL Directly in the Database (Alternative)

If the Magento Admin Panel isn’t accessible, you can update the Base URL directly in the database.

1. Access the Magento database (using MySQL CLI or a client like phpMyAdmin).

2. Run the following SQL commands:

? ?UPDATE core_config_data SET value = 'https://192.168.1.10/' WHERE path = 'web/unsecure/base_url';
? ?UPDATE core_config_data SET value = 'https://192.168.1.10/' WHERE path = 'web/secure/base        

3. Clear the cache with:

php bin/magento cache:clean        

Step 3: Configure Apache/Nginx to Allow Network Access

Ensure Magento’s web server (Apache or Nginx) is configured to accept connections from other systems on the network.

For Apache

1. Open the Apache configuration file for Magento (e.g,`/etc/apache2/sites-available/magento.conf`).

2. Locate any Require local or Allow from localhost settings and update them to allow access from the local network range:

? ?Require ip 192.168.1.0/24        

Replace 192.168.1.0/24 with your local network range.

3. Restart Apache:

? ?sudo systemctl restart apache2        

For Nginx

1. Open the Nginx configuration file for Magento (e.g., /etc/nginx/sites-available/magento).

2. Update the allow directive to include the local network:

? ?allow 192.168.1.0/24        

3. Restart Nginx:

? ?sudo systemctl restart nginx        

Step 4: Allow Firewall Access on the Magento System

If a firewall is enabled, ensure it allows incoming connections on the Magento port.

1. Open the necessary port for Magento on the local network:

sudo ufw allow from 192.168.1.0/24 to any port MAGENTO_PORT? ?        

Replace MAGENTO_PORT with the port on which Magento is running (e.g., 8080).

Step 5: Update Hosts File for Seamless Access

On the Odoo system, you can map the Magento server’s IP to a hostname in the hosts file for easy access.

1. Edit the hosts file on the Odoo system:

?sudo nano /etc/hosts?        

2. Add an entry to map Magento’s IP address to a hostname:

192.168.1.10 magento.local        

3. Save the file. Now, you can access Magento using https://magento.local:MAGENTO_PORT.

Step 6: Test Access to Magento from Odoo

To ensure the Odoo system can successfully communicate with the Magento server, follow these steps:

  1. Test Connectivity: On the Odoo system, open a terminal or use an API testing tool (like Postman or cURL). Verify that the Magento server is reachable by testing the API endpoints. For instance, use a cURL command such as:
  2. Validate API Access: If the connection is configured correctly, the Odoo system should be able to interact with Magento’s API, enabling integration and data exchange between the two platforms.

Summary

By following these steps, you will set up your Magento server to allow access from the Odoo server, facilitating API integration and testing within the local network. This configuration not only resolves connectivity issues but also optimizes the integration process. With Magento’s data readily accessible in Odoo, you can enhance operational efficiency and enable advanced testing and synchronization.

Whether you're troubleshooting connectivity or preparing for a full-scale integration project, this setup provides a solid foundation for creating a seamless Odoo-Magento synergy on an Ubuntu-based network.

William McMahon

CEO at Gravitai | Drinking The Purple Juice (An Odoo Community Channel) → Subscribe on LinkedIn? For Everything Odoo ??

3 天前

Nice article, Arsalan Yasin - to play devils advocate here however, and it's one that always interests me. There is always going to be a case for the Magento integration, but would you recommend the long term switch to Odoo?

要查看或添加评论,请登录