Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

newbie trying to understand data structure
 
Jake99
Member
 
Total Posts:  32
Joined:  2008-10-30
 

Hello,

I am trying to understand the database schema and would like some help as I am a newbie at this. It seems that there is meta data stored within the tables as well which is great for scalability but challenging for us newbies. Could someone point me in the right direction, preferably with a simple query, on where to get all of the product information for a specific product_id? Any help would be greatly appreciated. I am trying to figure out which tables all join together to get the meta-data and data for product_id 16 as an example. Thanks.

Jake

 
Magento Community Magento Community
Magento Community
Magento Community
 
nikefido
Guru
 
Avatar
Total Posts:  481
Joined:  2008-07-11
New Haven, CT
 

Magento is design so most of your customizations will work through the database abstraction layer. This is a fancy term which means “Magento has functions built in so you don’t have to worry about making complex SQL queries”

Of course, this adds the complication of learning the code in Magento, which isn’t well documented.

Anyway, search around the Block code in app/code/core/mage/Catalog/Block/Product and you will see code dealing with “collections”

These are the product collections being queried from the database. So you’ll see something like:

$collection Mage::getModel('catalog/product')->getCollection
      
->addAttributeToFilter('some attribute')
      ->
addAttributeToSelect('*');  //select all attributes

This $collection object will then be used in a template. For instance, you might see something liek this in a List.phtml template file (which lists products in a category)

$products = $this->getProductCollection();
foreach($products as $_product) {
echo $_product->getDescription(); //description is an attribute of the product
}

This is just scratching the surface....but hopefully it helps you understand Magento a bit more.

Magento uses a lot of advanced programming techniques. Understanding OOP and Design Patterns will help you immensely. (As well as understanding the Zend Framework, on which Magento is built).

 
Magento Community Magento Community
Magento Community
Magento Community
 
nikefido
Guru
 
Avatar
Total Posts:  481
Joined:  2008-07-11
New Haven, CT
 

If you are really interested in the database (which you will be eventually...) you can view the WIki articles on it - there is a downloadable PDF / HUGE image of the database architecture.

Also, you might want to look up “EAV database” in Google or Wikipedia to read how it works. If you’re familiar with “normal” database normalization rules, you will have a slightly better time understanding how EAV works.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Jake99
Member
 
Total Posts:  32
Joined:  2008-10-30
 

Nikefido,

Thank you for the response. I have been tasked as an intern to pull data that contains products in a non normalized SQL Server database and put them into the magento backend. I am trying to figure out which insert/update statements I have to build for the project. The spec is that multiple products are loaded nightly via a batch into this old legacy backend, which unfortunately has to stick around, I then have to push inserts/updates to the magento backend. I saw the import/export feature however my boss doesn’t want a manual process. Do you or someone else have a suggestion on where to proceed? I saw the magento schema and am lost so that is why I was looking for some direction on where this information was stored. If anyone could point me in the correct direction I would appreciate it. I have no problem staying up late and reading. Thanks in advance.

Jake

 
Magento Community Magento Community
Magento Community
Magento Community
 
Mad Martigan
Member
 
Total Posts:  44
Joined:  2008-08-17
Medford, OR USA
 

Hi jake99,

In addition to nikefido’s excellent advice, you may want to look at the web services API for magento.  You can use SOAP or XML-RPC to get at some magento information.  You can find the API specs here....

Magento API Information

Good luck.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Jake99
Member
 
Total Posts:  32
Joined:  2008-10-30
 

Thanks guys for the advice. I’ll start doing some reading!!!!

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top