How to get value from sales_flat_order_item table using quote_item_id? Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?I want to alter the new custom fields to sales_flat_order and sales_flat_order_item tableHow to get collection from table 'sales_flat_creditmemo_item'save custom field from sales_flat_order_item to sales_flat_orderHow can I get special price of an ordered product in “sales_flat_order_item” tableget cart items from custom column valueMagento model not fetching dataUpdate “sales_flat_order_item” table when making an orderHow do i get to Magento Table value using APIGet custom values from sales_flat_order_item table in magento?Bundle items are missing from sales_flat_order_item table. Magento 1.9

Who can become a wight?

Why did Israel vote against lifting the American embargo on Cuba?

Are there any AGPL-style licences that require source code modifications to be public?

Pointing to problems without suggesting solutions

Does GDPR cover the collection of data by websites that crawl the web and resell user data

Can a Knight grant Knighthood to another?

Determine the generator of an ideal of ring of integers

Is Vivien of the Wilds + Wilderness Reclimation a competitive combo?

Is there a verb for listening stealthily?

What kind of capacitor is this in the image?

Is there a way to convert Wolfram Language expression to string?

Does using the inspiration rules for character defects tend to encourage players to display MGS?

IC on Digikey is 5x more expensive than board containing same IC on Alibaba: How?

Reflections in a Square

What helicopter has the most rotor blades?

Can I ask an author to send me his ebook?

/bin/ls sorts differently than just ls

Weaponising the Grasp-at-a-Distance spell

reduction from 3-SAT to Subset Sum problem

Married in secret, can marital status in passport be changed at a later date?

Can a Wizard take the Magic Initiate feat and select spells from the Wizard list?

false 'Security alert' from Google - every login generates mails from 'no-reply@accounts.google.com'

What documents does someone with a long-term visa need to travel to another Schengen country?

Should man-made satellites feature an intelligent inverted "cow catcher"?



How to get value from sales_flat_order_item table using quote_item_id?



Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?I want to alter the new custom fields to sales_flat_order and sales_flat_order_item tableHow to get collection from table 'sales_flat_creditmemo_item'save custom field from sales_flat_order_item to sales_flat_orderHow can I get special price of an ordered product in “sales_flat_order_item” tableget cart items from custom column valueMagento model not fetching dataUpdate “sales_flat_order_item” table when making an orderHow do i get to Magento Table value using APIGet custom values from sales_flat_order_item table in magento?Bundle items are missing from sales_flat_order_item table. Magento 1.9



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















Using the sales_order_place_after event in my custom Observer.

I have the quote_item_id value (example 324).
How to get the corresponding item_id value from the sales_flat_order_item table?



I am able to successfully use getCollection method, but it returns the order item as an array.

($sales_order_item_id in below example)



How to get the string value? Eg 224 in example table

(in an efficient manner)



class Custom_Model_Observer 
public function booking(Varien_Event_Observer $observer)
$OrderId = $observer->getEvent()->getOrder()->getId(); //order entity id
$QuoteObject = Mage::getSingleton('checkout/session')->getQuote(); //quote object

foreach ($QuoteObject->getAllVisibleItems() as $item)

//get the quote item id - in example $quote_itemId = 324
$quote_itemId = $item->getData('item_id');

//get data from sales_flat_order_item table
$sales_order_item_id = Mage::getModel('sales/order_item')
->getCollection()
->addFieldToFilter('quote_item_id', $quote_itemId)
->getData('item_id');
//do more stuff here






Example sales_flat_order_item table:



sales_flat_order_item table










share|improve this question
























  • $sales_order_item_id = Mage::getModel('sales/order_item')->getCollection()->addFieldToFilter('quote_item_id', $quote_itemId)->getItemId();

    – Aaditya
    2 hours ago











  • Did already try that, but not working. Code stops dead, no log error, no exception.

    – Dan
    2 hours ago

















0















Using the sales_order_place_after event in my custom Observer.

I have the quote_item_id value (example 324).
How to get the corresponding item_id value from the sales_flat_order_item table?



I am able to successfully use getCollection method, but it returns the order item as an array.

($sales_order_item_id in below example)



How to get the string value? Eg 224 in example table

(in an efficient manner)



class Custom_Model_Observer 
public function booking(Varien_Event_Observer $observer)
$OrderId = $observer->getEvent()->getOrder()->getId(); //order entity id
$QuoteObject = Mage::getSingleton('checkout/session')->getQuote(); //quote object

foreach ($QuoteObject->getAllVisibleItems() as $item)

//get the quote item id - in example $quote_itemId = 324
$quote_itemId = $item->getData('item_id');

//get data from sales_flat_order_item table
$sales_order_item_id = Mage::getModel('sales/order_item')
->getCollection()
->addFieldToFilter('quote_item_id', $quote_itemId)
->getData('item_id');
//do more stuff here






Example sales_flat_order_item table:



sales_flat_order_item table










share|improve this question
























  • $sales_order_item_id = Mage::getModel('sales/order_item')->getCollection()->addFieldToFilter('quote_item_id', $quote_itemId)->getItemId();

    – Aaditya
    2 hours ago











  • Did already try that, but not working. Code stops dead, no log error, no exception.

    – Dan
    2 hours ago













0












0








0








Using the sales_order_place_after event in my custom Observer.

I have the quote_item_id value (example 324).
How to get the corresponding item_id value from the sales_flat_order_item table?



I am able to successfully use getCollection method, but it returns the order item as an array.

($sales_order_item_id in below example)



How to get the string value? Eg 224 in example table

(in an efficient manner)



class Custom_Model_Observer 
public function booking(Varien_Event_Observer $observer)
$OrderId = $observer->getEvent()->getOrder()->getId(); //order entity id
$QuoteObject = Mage::getSingleton('checkout/session')->getQuote(); //quote object

foreach ($QuoteObject->getAllVisibleItems() as $item)

//get the quote item id - in example $quote_itemId = 324
$quote_itemId = $item->getData('item_id');

//get data from sales_flat_order_item table
$sales_order_item_id = Mage::getModel('sales/order_item')
->getCollection()
->addFieldToFilter('quote_item_id', $quote_itemId)
->getData('item_id');
//do more stuff here






Example sales_flat_order_item table:



sales_flat_order_item table










share|improve this question
















Using the sales_order_place_after event in my custom Observer.

I have the quote_item_id value (example 324).
How to get the corresponding item_id value from the sales_flat_order_item table?



I am able to successfully use getCollection method, but it returns the order item as an array.

($sales_order_item_id in below example)



How to get the string value? Eg 224 in example table

(in an efficient manner)



class Custom_Model_Observer 
public function booking(Varien_Event_Observer $observer)
$OrderId = $observer->getEvent()->getOrder()->getId(); //order entity id
$QuoteObject = Mage::getSingleton('checkout/session')->getQuote(); //quote object

foreach ($QuoteObject->getAllVisibleItems() as $item)

//get the quote item id - in example $quote_itemId = 324
$quote_itemId = $item->getData('item_id');

//get data from sales_flat_order_item table
$sales_order_item_id = Mage::getModel('sales/order_item')
->getCollection()
->addFieldToFilter('quote_item_id', $quote_itemId)
->getData('item_id');
//do more stuff here






Example sales_flat_order_item table:



sales_flat_order_item table







magento-1.9 collection sales-order quoteitem






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 3 hours ago







Dan

















asked 3 hours ago









DanDan

175




175












  • $sales_order_item_id = Mage::getModel('sales/order_item')->getCollection()->addFieldToFilter('quote_item_id', $quote_itemId)->getItemId();

    – Aaditya
    2 hours ago











  • Did already try that, but not working. Code stops dead, no log error, no exception.

    – Dan
    2 hours ago

















  • $sales_order_item_id = Mage::getModel('sales/order_item')->getCollection()->addFieldToFilter('quote_item_id', $quote_itemId)->getItemId();

    – Aaditya
    2 hours ago











  • Did already try that, but not working. Code stops dead, no log error, no exception.

    – Dan
    2 hours ago
















$sales_order_item_id = Mage::getModel('sales/order_item')->getCollection()->addFieldToFilter('quote_item_id', $quote_itemId)->getItemId();

– Aaditya
2 hours ago





$sales_order_item_id = Mage::getModel('sales/order_item')->getCollection()->addFieldToFilter('quote_item_id', $quote_itemId)->getItemId();

– Aaditya
2 hours ago













Did already try that, but not working. Code stops dead, no log error, no exception.

– Dan
2 hours ago





Did already try that, but not working. Code stops dead, no log error, no exception.

– Dan
2 hours ago










1 Answer
1






active

oldest

votes


















0














Normally you can iterate through the order item collection and get both - the item_id and the quote_item_id in one loop, like this



$order = $observer->getEvent()->getOrder();
foreach ($order->getAllVisibleItems() as $orderItem)
//quote_item_id
$orderItem->getQuoteItemId();
//item_id
$orderItem->getId();



But I'm not sure that there already exist the item_id in the event you are using, sales_order_place_after.
That id is available only after the order and the order items are saved in the database. The right event for accessing that data would be sales_order_save_after.






share|improve this answer























  • in your example (using sales_order_save_after event), does $orderItem->getId(); get the order id, or the order item id? I was able to extract the 'item_id' by using $orderitem_id_value = $sales_order_item_id[0]['item_id']; from the array, but this seems so inefficient. I will test your suggestion.

    – Dan
    2 hours ago












  • $orderItem->getId() is the order item id. $order->getId() would be the order id.

    – HelgeB
    2 hours ago











Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f270991%2fhow-to-get-value-from-sales-flat-order-item-table-using-quote-item-id%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Normally you can iterate through the order item collection and get both - the item_id and the quote_item_id in one loop, like this



$order = $observer->getEvent()->getOrder();
foreach ($order->getAllVisibleItems() as $orderItem)
//quote_item_id
$orderItem->getQuoteItemId();
//item_id
$orderItem->getId();



But I'm not sure that there already exist the item_id in the event you are using, sales_order_place_after.
That id is available only after the order and the order items are saved in the database. The right event for accessing that data would be sales_order_save_after.






share|improve this answer























  • in your example (using sales_order_save_after event), does $orderItem->getId(); get the order id, or the order item id? I was able to extract the 'item_id' by using $orderitem_id_value = $sales_order_item_id[0]['item_id']; from the array, but this seems so inefficient. I will test your suggestion.

    – Dan
    2 hours ago












  • $orderItem->getId() is the order item id. $order->getId() would be the order id.

    – HelgeB
    2 hours ago















0














Normally you can iterate through the order item collection and get both - the item_id and the quote_item_id in one loop, like this



$order = $observer->getEvent()->getOrder();
foreach ($order->getAllVisibleItems() as $orderItem)
//quote_item_id
$orderItem->getQuoteItemId();
//item_id
$orderItem->getId();



But I'm not sure that there already exist the item_id in the event you are using, sales_order_place_after.
That id is available only after the order and the order items are saved in the database. The right event for accessing that data would be sales_order_save_after.






share|improve this answer























  • in your example (using sales_order_save_after event), does $orderItem->getId(); get the order id, or the order item id? I was able to extract the 'item_id' by using $orderitem_id_value = $sales_order_item_id[0]['item_id']; from the array, but this seems so inefficient. I will test your suggestion.

    – Dan
    2 hours ago












  • $orderItem->getId() is the order item id. $order->getId() would be the order id.

    – HelgeB
    2 hours ago













0












0








0







Normally you can iterate through the order item collection and get both - the item_id and the quote_item_id in one loop, like this



$order = $observer->getEvent()->getOrder();
foreach ($order->getAllVisibleItems() as $orderItem)
//quote_item_id
$orderItem->getQuoteItemId();
//item_id
$orderItem->getId();



But I'm not sure that there already exist the item_id in the event you are using, sales_order_place_after.
That id is available only after the order and the order items are saved in the database. The right event for accessing that data would be sales_order_save_after.






share|improve this answer













Normally you can iterate through the order item collection and get both - the item_id and the quote_item_id in one loop, like this



$order = $observer->getEvent()->getOrder();
foreach ($order->getAllVisibleItems() as $orderItem)
//quote_item_id
$orderItem->getQuoteItemId();
//item_id
$orderItem->getId();



But I'm not sure that there already exist the item_id in the event you are using, sales_order_place_after.
That id is available only after the order and the order items are saved in the database. The right event for accessing that data would be sales_order_save_after.







share|improve this answer












share|improve this answer



share|improve this answer










answered 2 hours ago









HelgeBHelgeB

3,4181423




3,4181423












  • in your example (using sales_order_save_after event), does $orderItem->getId(); get the order id, or the order item id? I was able to extract the 'item_id' by using $orderitem_id_value = $sales_order_item_id[0]['item_id']; from the array, but this seems so inefficient. I will test your suggestion.

    – Dan
    2 hours ago












  • $orderItem->getId() is the order item id. $order->getId() would be the order id.

    – HelgeB
    2 hours ago

















  • in your example (using sales_order_save_after event), does $orderItem->getId(); get the order id, or the order item id? I was able to extract the 'item_id' by using $orderitem_id_value = $sales_order_item_id[0]['item_id']; from the array, but this seems so inefficient. I will test your suggestion.

    – Dan
    2 hours ago












  • $orderItem->getId() is the order item id. $order->getId() would be the order id.

    – HelgeB
    2 hours ago
















in your example (using sales_order_save_after event), does $orderItem->getId(); get the order id, or the order item id? I was able to extract the 'item_id' by using $orderitem_id_value = $sales_order_item_id[0]['item_id']; from the array, but this seems so inefficient. I will test your suggestion.

– Dan
2 hours ago






in your example (using sales_order_save_after event), does $orderItem->getId(); get the order id, or the order item id? I was able to extract the 'item_id' by using $orderitem_id_value = $sales_order_item_id[0]['item_id']; from the array, but this seems so inefficient. I will test your suggestion.

– Dan
2 hours ago














$orderItem->getId() is the order item id. $order->getId() would be the order id.

– HelgeB
2 hours ago





$orderItem->getId() is the order item id. $order->getId() would be the order id.

– HelgeB
2 hours ago

















draft saved

draft discarded
















































Thanks for contributing an answer to Magento Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f270991%2fhow-to-get-value-from-sales-flat-order-item-table-using-quote-item-id%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

六本木駅

Integral that is continuous and looks like it converges to a geometric seriesTesting if a geometric series converges by taking limit to infinitySummation of arithmetic-geometric series of higher orderGeometric series with polynomial exponentHow to Recognize a Geometric SeriesShowing an integral equality with series over the integersDiscontinuity of a series of continuous functionsReasons why a Series ConvergesSum of infinite geometric series with two terms in summationUsing geometric series for computing IntegralsLimit of geometric series sum when $r = 1$

Joseph Lister