0

I use below code to bootstrap Magento in an external script, which works. As an example it gets the name of a specific product.

Is it possible to connect to another Magento database (on the same server) from such a script? If yes, how would I do this? I tried several things but didn't got a working end result.

<?php

require_once '../app/Mage.php';
Mage::app();

$sku = 'product X';
$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $sku);

var_dump($product->getName());

1 Answer 1

0

This is achievable. You need to define database credentials in your local.xml where you have your script placed. You can have something like below:

enter image description here

Once you have some create a module / model to connect to second database and play around it to achieve what you want.

1
  • Thanks. I just want to use Magento default models. For example get a product with 'catalog/product' model from the second database. How would I do that? Can you give an example?
    – Akif
    Commented Sep 5, 2018 at 21:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.