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

2
  • why you need sql query you can get all data via magento syntax Oct 28, 2016 at 11:50
  • I am new in magento. I have a this task so please suggest me. 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

5
  • Thanks, But I want to get cart information using custom sql query. Oct 28, 2016 at 12:05
  • you get cart information from this code Oct 28, 2016 at 12:05
  • Yes I know but i want to cart information using custom sql query. so please suggest me. Oct 28, 2016 at 12:12
  • why you need custom query ?? please tell me so I can provide you better answer Oct 28, 2016 at 12:13
  • I have get a this task. so please 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();

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.