头部购物车里不显示商品的bug

来源:互联网 发布:如何在手机淘宝上开店 编辑:程序博客网 时间:2024/04/30 23:58

涉及到以下几个文件

app\design\frontend\default\theme508\template\checkout\cart\sidebar_header.phtml

<?php/** * Magento * * NOTICE OF LICENSE * * This source file is subject to the Academic Free License (AFL 3.0) * that is bundled with this package in the file LICENSE_AFL.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/afl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@magentocommerce.com so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade Magento to newer * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * * @category    design * @package     base_default * @copyright   Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com) * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0) *//** * Shoping cart sidebar * * @see Mage_Checkout_Block_Cart_Sidebar */?><?php if ($this->getIsNeedToDisplaySideBar()):?><div class="block-cart-header">    <?php $_cartQty = $this->getSummaryCount() ?>    <h3><?php echo $this->__('Cart') ?>:</h3>    <div class="block-content">    <?php if ($_cartQty>0): ?>        <div class="summary">            <?php if ($_cartQty==1): ?>                <p class="amount-2"><?php echo $this->__('<strong title="%s">%s item</strong>', $this->getUrl('checkout/cart'), $_cartQty) ?> -<?php echo Mage::helper('checkout')->formatPrice($this->getSubtotal()) ?></p>            <?php else: ?>                <p class="amount-2"><?php echo $this->__('<strong title="%s">%s items</strong>', $this->getUrl('checkout/cart'), $_cartQty) ?> -<?php echo Mage::helper('checkout')->formatPrice($this->getSubtotal()) ?></p>            <?php endif ?></div>            <div class="cart-content">                <div class="cart-indent">                    <p class="subtotal">                        <?php if ($this->canApplyMsrp()): ?>                            <span class="map-cart-sidebar-total"><?php echo $this->__('ORDER TOTAL WILL BE DISPLAYED BEFORE YOU SUBMIT THE ORDER'); ?></span>                        <?php else: ?>                            <span class="label"><?php echo $this->__('Cart Subtotal:') ?></span> <?php echo Mage::helper('checkout')->formatPrice($this->getSubtotal()) ?>                            <?php if ($_subtotalInclTax = $this->getSubtotalInclTax()): ?>                                <br />(<?php echo Mage::helper('checkout')->formatPrice($_subtotalInclTax) ?> <?php echo Mage::helper('tax')->getIncExcText(true) ?>)                            <?php endif; ?>                        <?php endif; ?>                    </p>                    <?php endif ?>                    <?php if($_cartQty && $this->isPossibleOnepageCheckout()): ?>                    <?php endif ?>                    <?php $_items = $this->getRecentItems() ?>                    <?php if(count($_items)): ?>                        <p class="block-subtitle"><?php echo $this->__('Recently added item(s)') ?></p><span style="background-color: rgb(255, 102, 102);">                        <ol id="cart-sidebar" class="mini-products-list">                        <?php foreach($_items as $_item): ?>                        <?php echo $_item; ?>                            <?php echo $this->getItemHtml($_item) ?>                        <?php endforeach; ?>                        </ol>  </span>                    <div class="actions">                        <button type="button" title="<?php echo $this->__('Checkout') ?>" class="button" onclick="setLocation('<?php echo $this->getCheckoutUrl() ?>')"><span><span><?php echo $this->__('Checkout') ?></span></span></button>                        <button type="button" title="<?php echo $this->__('My Cart') ?>" class="button" onclick="setLocation('<?php echo $this->getUrl('checkout/cart') ?>')"><span><span><?php echo $this->__('My Cart') ?></span></span></button>                    </div>                    <script type="text/javascript">decorateList('cart-sidebar', 'none-recursive')</script>                </div>            </div>    <?php else: ?>        <div class="empty"><?php echo $this->__('0 item(s)') ?> - <?php echo Mage::helper('checkout')->formatPrice($this->getSubtotal()) ?>            <div class="cart-content"><?php echo $this->__('You have no items in your shopping cart.') ?>            </div>        </div>    <?php endif ?>    </div></div><?php endif;?>

app\design\frontend\default\theme508\layout\page.xml

<block type="page/html_header" name="header" as="header"><block type="checkout/cart_sidebar" name="cart_header" template="checkout/cart/sidebar_header.phtml">                    <action method="addItemRender"><type>simple</type><block>checkout/cart_item_renderer</block><template>checkout/cart/sidebar/default.phtml</template></action>                    <action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/cart/sidebar/default.phtml</template></action>                    <action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/cart/sidebar/default.phtml</template></action>                    <block type="core/text_list" name="cart_sidebar.extra_actions" as="extra_actions" translate="label" module="checkout">                        <label>Shopping Cart Sidebar Extra Actions</label>                    </block>                </block>                <block type="page/template_links" name="top.links" as="topLinks"/>                <block type="page/template_links" name="top.links.left" as="topLinksLeft"/>                <block type="page/switch" name="store_language" as="store_language" template="page/switch/languages.phtml"/><block type="directory/currency" name="currency" template="directory/currency.phtml"/>                <block type="core/text_list" name="top.menu" as="topMenu" translate="label">                    <label>Navigation Bar</label>                    <block type="page/html_topmenu" name="catalog.topnav" template="page/html/topmenu.phtml"/>                </block>                <block type="page/html_wrapper" name="top.container" as="topContainer" translate="label">                    <label>Page Header</label>                    <action method="setElementClass"><value>top-container</value></action>                </block>            </block>
按以上逻辑,应该获取的是下面的模板
app\design\frontend\default\theme508\template\checkout\cart\sidebar\default.phtml

但是在less var/log/system.log 中找到如下错误

CRIT (2): Not valid template file:frontend/base/default/template/ajax/checkout/cart/sidebar/default.phtml


可见是去取了其他地方的模板

app\code\local\Excellence\Ajax\Block\Cart\Sidebar.php

<?phpclass Excellence_Ajax_Block_Cart_Sidebar extends Mage_Checkout_Block_Cart_Sidebar{public function getItemRenderer($type){if (!isset($this->_itemRenders[$type])) {$type = 'default';}if (is_null($this->_itemRenders[$type]['blockInstance'])) {$this->_itemRenders[$type]['blockInstance'] = $this->getLayout()->createBlock($this->_itemRenders[$type]['block'])->setTemplate('ajax/checkout/cart/sidebar/default.phtml')->setRenderedBlock($this);}if (is_null($this->_itemRenders[$type]['blockInstance'])) {$this->_itemRenders[$type]['blockInstance'] = $this->getLayout()->createBlock($this->_itemRenders[$type]['block'])->setTemplate('ajax/checkout/cart/sidebar_header.phtml')->setRenderedBlock($this);}return $this->_itemRenders[$type]['blockInstance'];}}

注释了还是没解决问题

故将 cp /home/promlove/public_html/app/design/frontend/default/theme508/template/checkout/cart/sidebar/default.phtml 复制到

/home/promlove/public_html/app/design/frontend/base/default/template/ajax/checkout/cart/sidebar/default.phtml 

done!


0 0