Integration of a custom maria db database into Pimcore data model

Hello,

I am a Pimcore beginner and I am wondering how to handle Products which are stored into an external database. My scope is to integrate these products in the pimcore data model and manipulate them in the backoffice. I read the documentation related to the Data Model
https://pimcore.com/docs/pimcore/current/Development_Documentation/Development_Tools_and_Details/Database_Model.html

But there’s not any explanation on how Pimcore communicates with an external DB.

Many thanks for your support.
Regards,
Giuseppe.

Hi Giuseppe

add external DB configuration to your app/config/local/database.yml

doctrine:
    dbal:
        connections:
            default:
                user: pimcore
                password: pimcore
                dbname: pimcore
                host: localhost
                port: 3306
            external:
                user: ex-user
                password: ex-password
                dbname: external-database
                host: localhost
                port: 3306

Next in your controller:

$db = \Pimcore::getContainer()->get('doctrine.dbal.external_connection');
$list = $db->fetchAll('select * from external_table limit 10');
1 Like