1

How to get customer shopping cart information using custom sql query.

I want to get shopping cart product information like below.

for example ::

product_name,
product_id,
product_image,
qty,
row_total,
is_in_stock,
base_subtotal,
base_grand_total,
shipping_amount,
street

Murtuza Zabuawala
14.8k10 gold badges47 silver badges76 bronze badges
asked Oct 28, 2016 at 11:18
2
  • why you need sql query you can get all data via magento syntax Commented Oct 28, 2016 at 11:50
  • I am new in magento. I have a this task so please suggest me. Commented Oct 28, 2016 at 11:53

2 Answers 2

0

you can get current customer cart/quote detail from below code

$cart = Mage::getSingleton('checkout/session')->getQuote();
foreach ($cart->getAllItems() as $item) {
 $product = Mage::getModel('catalog/product')->load($item->getProductId()) ;
 echo $product->getName();
}

you can get all data from $product as it is a product object so you can easily access product data

answered Oct 28, 2016 at 11:58
5
  • Thanks, But I want to get cart information using custom sql query. Commented Oct 28, 2016 at 12:05
  • you get cart information from this code Commented Oct 28, 2016 at 12:05
  • Yes I know but i want to cart information using custom sql query. so please suggest me. Commented Oct 28, 2016 at 12:12
  • why you need custom query ?? please tell me so I can provide you better answer Commented Oct 28, 2016 at 12:13
  • I have get a this task. so please Commented Oct 28, 2016 at 12:17
-1

You can get the code for it in

app/design/frontend/[Your-package]/[Your-theme]/template/Checkout/Cart

There you will find snippet like this

$cart = Mage::getSingleton('checkout/session')->getQuote();
Murtuza Zabuawala
14.8k10 gold badges47 silver badges76 bronze badges
answered Oct 28, 2016 at 12:07

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.