views:

105

answers:

2

I am building a site that needs to display some product info from a Magento Database, but display it on another page/site outside the Magento intallation. I know the information gets displayed twice, but I would like the site to avoid content duplication and pull that same info from an only source, the Magento product database.

Is this posible? Has anyone done it?

A: 

Yes, I've done it a few ways. The safest way to do this is using the webservices Magento exposes to query objects programmatically. This will insulate you from database-level changes (such as the flat product catalog, a recent addition).

Failing that (if the performance of the webservices doesn't meet your needs), you can reconstruct the catalog data from the database directly. Use the following tables (assuming you're not using the flat catalog):

eav_entity_type
eav_attribute
catalog_product_entity
catalog_product_entity_int
catalog_product_entity_varchar
catalog_product_entity_text
catalog_product_entity_decimal
catalog_product_entity_datetime

You'll want to read up on EAV models before you attempt this. Bear in mind that this is largely the topic over which people call Magento complicated.

Hope that helps!

Thanks, Joe

Joseph Mastey
Should I convert the EAV database to a FLAT database for an easier approach?
Landitus
+1  A: 

What would be a lot easier to do would be to pull in the entire Magento engine into your external page. This [unlike the rest of Magento] is pretty easy to do.

All you have to do is the following:

// Load Up Magento Core define('MAGENTO', realpath('/var/www/magento/'));

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

$app = Mage::app();

Now you can use any of the Magento objects/classes as if you were inside of Magento and get your attributes

$product = Mage::getModel('catalog/product')->load(1234);
$product->getSku();
$product->getYourCustomAttribute();

etc etc.

Josh Pennington
If your page is not on the same server I would consider using the Magento API to get your product data.
Josh Pennington
WOW! lots of options! Thanks Josh. Magento seems overly complicated for some simple tasks. I would really like to try both your solutions. I guess the API seems like the tidy way to go around it.
Landitus