【问题标题】:Magento - Cannot get cart info into an external pageMagento - 无法将购物车信息获取到外部页面
【发布时间】:2011-11-09 04:36:14
【问题描述】:

我已将 magento 安装在名为 store 的文件夹中。最小站点安装在主机根目录的上方。

我遵循了很多关于如何让购物车显示在外部页面上的想法,但我似乎无法从 magento 获得任何信息。

<?
$mageFilename = 'store/app/Mage.php';
require_once $mageFilename;

umask(0);
Mage::app();

/* Init User Session */
$session = Mage::getSingleton('customer/session', array('name'=>'frontend'));

if ($session->isLoggedIn()) {
echo'logged in <br />';
/* do something if logged in */
} else {
echo'not logged in<br />';
/* do something else if not logged in */
}

/* Magento uses different sessions for 'frontend' and 'adminhtml' */
Mage::getSingleton('core/session', array('name'=>'frontend'));

$cart = Mage::helper('checkout/cart')->getCart()->getItemsCount();

echo 'cart items count: ' . $cart;
?>

我目前有这个代码来调用购物车中的商品数量,并说明用户是否登录。但似乎什么都没有传递给它。

【问题讨论】:

    标签: magento


    【解决方案1】:

    我相信你必须从 Magento 控制器运行它。

    Magento 是一个非常强大、先进、专业的 PHP 平台。它目前最先进的 PHP MVC 框架之一。如果您正在尝试构建一个包含 Magento 存储的 PHP 站点,为什么不使用 Magento 构建整个站点呢?您使用的是更好的平台吗?

    【讨论】:

    • 我有自己的网站其他部分的内容管理系统。但是我在商店方面使用magento。我想将购物车信息从 magento 中取出并显示在网站的其他部分
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多