Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6864747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:57:04+00:00 2026-05-27T02:57:04+00:00

could some one please explain this snippet of magento code found in loadByCustomerId() in

  • 0

could some one please explain this snippet of magento code found in loadByCustomerId() in the class Mage_Sales_Model_Mysql4_Quote.

$read = $this->_getReadAdapter();
$select = $this->_getLoadSelect('customer_id', $customerId, $quote)
                ->where('is_active=1')
                ->order('updated_at desc')
                ->limit(1);
$data = $read->fetchRow($select);

When i var_dump($data) i see that its an array of customer data. What is model associated with this $data array? Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T02:57:04+00:00Added an answer on May 27, 2026 at 2:57 am

    Magento “Models” (meaning the entities that allow you to interact with the database, not general purpose server/domain models) have two layers. The first is the “Model” layer. This contains methods for logical interactive with an model. (get me a customer’s address, place the order, etc). The second layer is the “Resource Model” layer. Resource Models handle any interactive with the database (or,more generally, the data-store,or the persistance layer, or etc.).

    The way a Resource Model interacts with the database is via adapter objects. One for reading information, another for writing information.

    So, you’re in the class Mage_Sales_Model_Mysql4_Quote. This is a Resource Model. It’s the backend for the Mage_Sales_Model_Quote object, instantiated with

    $model = Mage::getModel('sales/quote');
    

    With this line

    $read = $this->_getReadAdapter();
    

    you’re getting a reference to the model’s read adapter. This will let you make queries to the database.

    With this line

    $select = $this->_getLoadSelect('customer_id', $customerId, $quote)
                    ->where('is_active=1')
                    ->order('updated_at desc')
                    ->limit(1);
    

    You’re getting a reference to the SQL statement (also an object) that this Resource Model will use to load a sales/quote object.

    //gets a reference
    $this->_getLoadSelect('customer_id', $customerId, $quote)
    

    Then, you’re calling methods on that object to alter it with additional logic

    ->where('is_active=1')
    ->order('updated_at desc')
    ->limit(1);
    

    In pseudo sql, a query might look like this normally

    SELECT * FROM quote_table;
    

    But after you call those methods, the query will look something like

    SELECT * FROM quote_table
    WHERE is_active = 1
    ORDER BY updated_at desc
    LIMIT 1;
    

    Finally,

    $data = $read->fetchRow($select);
    

    here you’re using the read adapter you fetched earlier to make a query into the database for the specific quote item row that your query will fetch.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Could someone please explain function(tx) in the code snippet below, from this page: http://www.webkit.org/demos/sticky-notes/
could someone please explain this java code for me. i find it really hard
can some one please explain to me how I could go about converting a
Could someone please help explain why I can't get this to work? I properly
Can anybody please explain how this could possibly happen? I am completely aware of
I am exploring Qt source code and came across this Q_D macro. Could some
Could someone explain this behaviour to me? If you execute the snippet at the
Could someone please explain the best way to connect to an Interbase 7.1 database
Could someone please explain? I couldn't find anything on the internet, everything talks about
Could someone please explain when would I want to use delegation instead of inheritance?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.