0

I have set my resource model up, my model for it and I have pulled Item 1 from the database...

How do I select rows from the database that have a 'quote_id' of say 9?

 public function getQuoteProducts()
 {
   $quoteDataModel = $this->_quoteDataModelFactory->create();
    $item = $quoteDataModel->load(1);
    var_dump($item->getData());
    ...And so on.
 }

1 Answer 1

1

You should be able to just pass in the quote ID you wish to load, so you could change your function to something like this.

public function getQuoteProducts($quoteid)
 {
   $quoteDataModel = $this->_quoteDataModelFactory->create();
    $item = $quoteDataModel->load($quoteid);
    var_dump($item->getData());
    return $this->_quote->getQuoteProducts();
 }

and then call your function

$this->getQuoteProducts(9);
3
  • Ah, so that ->load function that I did not define is working according to the table entry primary??? What if I want to load by a different field? Commented Jun 28, 2016 at 10:07
  • It depends on the field really, i know in magento1 there is a loadByCustomer() function where you can pass in a customer, i should imagine this exists in magento2 aswell. Commented Jun 28, 2016 at 10:12
  • 2
    ->load($value, $fieldname) works for me, but it will only load one, and if the value isn't unique it won't warn you there are more. Commented Jun 28, 2016 at 10:17

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.