Magento购物车/Magento以外的会话数据 [英] Magento cart / session data outside magento

查看:101
本文介绍了Magento购物车/Magento以外的会话数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能会使我感到困惑,因为我已尽一切努力使这项工作生效.我想要的只是品牌网站(domain.com)中的链接,该链接显示了我的magento 1.5.1购物车(domain.com/shop)中的数量,我很容易拉入产品数据和导航块,但是无论我做什么,外部magento的购物车数量始终为0. 我尝试的主要方式只是在我的品牌网站上进行:

This might get a little confusing as I have tried everything to make this work. All I want is a link in my brand site (domain.com) which shows the qty in my magento 1.5.1 cart (domain.com/shop) I quite easily pulled in product data and navigation blocks but no matter what I do, cart qty is always 0 from outside magento. The main way I tried was just in my brand site to go:

    require_once $_SERVER['DOCUMENT_ROOT'].'/shop/app/Mage.php';
    umask(0);
    Mage::app();        
    Mage::getSingleton('core/session', array('name'=>'frontend'));
    // trying everything 
    Mage::getSingleton('checkout/cart')->getItemsCount(); // returns 0
    Mage::helper('checkout/cart')->getItemsCount(); // returns 0
    Mage::getSingleton('customer/session')->isLoggedIn(); // returns blank
    Mage::helper('checkout/cart')->getCart()->getItemsCount(); // returns 0
    Mage::helper('checkout/cart')->getCart()->getQuote()->getItemsCount(); // returns blank

然后,当这些都不工作,我创建了Magento的模板,只是给我的购物车数量作为返回购物车中的块罚款,但仍为零块!

Then, when none of those worked, I created a template in Magento just to give me the cart qty as a block which returns the block fine but still zero in the cart!

    $block = $this->layout->createBlock('core/template');
    $block->setTemplate('page/html/cartForBrand.phtml');
    return $block->renderView();

并且magento中的方块很简单

and the block in magento is simply

    Mage::getSingleton('core/session', array('name'=>'frontend'));
    $cart = Mage::getModel('checkout/cart')->getQuote()->getData()['items_qty'];

我已经看到了很多遇到类似问题的人:的/session_cookie_management .domain.com cookie_domain (尽管这是特定于子域​​的),但我已阅读并尝试了2天可以找到的所有内容.在禁用magento缓存的情况下,不断删除会话和缓存目录,并清除缓存和cookie.

I've seen a lot of people having similar issues: / session_cookie_management, .domain.com cookie_domain(even though that's subdomain specific), I've read and tried everything I could find for 2 days. Constantly deleting session and cache directories and clearing cache and cookies with magento caching disabled.

这是我使用多年以来在此网站上发布的第一个问题,我在此问题上停留了3天!拔我的头发!

This is the first question I've posted on this site after using it for years, I've been stuck on this for 3 days! Pulling my hair out!

推荐答案

如果你要的是数量在所有原因实例化的Magento.只需设置一个客户端cookie(即cart_qty),然后在您的主站点标题上读取此cookie.

If all you want is the qty why instantiate magento at all. Just set a client side cookie (ie cart_qty) and then read this cookie on your main site header.

这篇关于Magento购物车/Magento以外的会话数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆