开发者

Is it possible to query the Magento database and display product attributes outside Magento?

I am building a site that needs to di开发者_运维百科splay 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?


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜