【问题标题】:magento : get unit price from cartmagento:从购物车中获取单价
【发布时间】:2014-04-18 10:06:41
【问题描述】:

我正在开发自定义价格的扩展,我想知道如何从购物车中获取单价我试过这个:

$itemProduct = $this->getProduct();

        $cart = Mage::getModel('checkout/cart')->getQuote();
        foreach ($cart->getAllItems() as $item) {
            $productId = $item->getProduct()->getProductId();
            $productPrice = $item->getProduct()->getPrice();

            if($productId == $itemProduct->getId()){
                /*
                 * do our check for 'same product' here.
                * Returns true if attribute is the same thus it is hte same product
                */
                if ($productPrice == $itemProduct->getPrice()) {
                    return true; //same product
                } else {
                    return false; //different product
                }

            }

但它总是返回 false 我想我没有得到单价

怎么做?

【问题讨论】:

    标签: magento shopping-cart


    【解决方案1】:

    尝试直接访问数据库,例如:

    如果您要查找报价单价检查(表名:sales_flat_quote 然后列小计)

    如果您正在寻找销售单价,请查看(表名:sales_flat_order 然后列小计)

    这可以帮助您提高扩展速度(仅获取内容不添加)

    谢谢

    【讨论】:

      【解决方案2】:

      解决了这个问题:

      $productId = $item->getProduct()->getProductId();
      $productPrice = $item->getProduct()->getPrice();
      

      到这个:

      $productId = $item->getProductId();
      $productPrice = $item->getPrice();
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2013-02-18
        • 2015-01-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-10-30
        相关资源
        最近更新 更多