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
-
why you need sql query you can get all data via magento syntaxMurtuza Zabuawala– Murtuza Zabuawala ♦2016年10月28日 11:50:45 +00:00Commented Oct 28, 2016 at 11:50
-
I am new in magento. I have a this task so please suggest me.Rakesh Patidar– Rakesh Patidar2016年10月28日 11:53:53 +00:00Commented Oct 28, 2016 at 11:53
2 Answers 2
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
-
Thanks, But I want to get cart information using custom sql query.Rakesh Patidar– Rakesh Patidar2016年10月28日 12:05:23 +00:00Commented Oct 28, 2016 at 12:05
-
you get cart information from this code2016年10月28日 12:05:59 +00:00Commented Oct 28, 2016 at 12:05
-
Yes I know but i want to cart information using custom sql query. so please suggest me.Rakesh Patidar– Rakesh Patidar2016年10月28日 12:12:23 +00:00Commented Oct 28, 2016 at 12:12
-
why you need custom query ?? please tell me so I can provide you better answer2016年10月28日 12:13:47 +00:00Commented Oct 28, 2016 at 12:13
-
I have get a this task. so pleaseRakesh Patidar– Rakesh Patidar2016年10月28日 12:17:21 +00:00Commented Oct 28, 2016 at 12:17
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();