覆盖cart.phtml问题不适用于notitems.phtml

时间:2016-11-23 04:39:25

标签: magento

您好我正在努力覆盖cart.phtml,它运行正常。但问题是,当购物车中没有任何商品仍然显示购物车表页眉和页脚部分没有任何项目。我想当购物车中没有商品时,它会显示noitem.phtml内容,因为它适用于默认的magetno功能。

我检查了很多东西但没有工作。我已经更新了我的layout.xml但没有任何影响。

我的layout.xml

def generateReport(gradebook):
    outfile=open('gradebook.txt','w')

    # all the columns, in the order they need to show up.
    columns = ('ID', 'Exam1', 'Exam2', 'Homework', 'Attendance',
           'Project1', 'Project2', 'Class Recap',
           'Final Grade', 'Potential Grade')

    # join the columns into a tab-separated line with a newline, and write it once
    header_line = '\t'.join(columns) + '\n'
    outfile.write(header_line)

    # sort the student IDs into (numeric) order:
    sorted_student_ids = sorted(gradebook.keys(), key=int)

    # loop over each student ID
    for student_id in sorted_student_ids:

      # for each student, get their data
      student_data = gradebook[student_id]

      # build up a line of output for this students, using the columns
      student_row = []
      for column in columns:

        # columns don't match the dictionary keys :|
        # remove spaces and make them lowercase, so they do
        # also handle where there is no data for a column and get '' instead
        # and convert to strings for writing to the file
        column = column.replace(' ', '').lower()
        value = str(student_data.get(column, ''))

        student_row.append(value)

      # now we have the data for this student, in the desired column order
      student_line = '\t'.join(student_row) + '\n'
      outfile.write(student_line)

    outfile.close()


d={'37340752': {'exam1': '50', 'project1': '40', 'classrecap': '39', 'homework': '62', 'exam2': '3', 'attendance': '17', 'project2': '86', 'id': '37340752'},
   '95255664': {'exam1': '76', 'project1': '60', 'classrecap': '39', 'homework': '81', 'exam2': '57', 'attendance': '19', 'project2': '42', 'id': '95255664'},
   '47718233': {'exam1': '81', 'project1': '55', 'classrecap': '53', 'homework': '46', 'exam2': '46', 'attendance': '4', 'project2': '14', 'id': '47718233'},
   '55527760': {'exam1': '34', 'project1': '89', 'classrecap': '39', 'homework': '19', 'exam2': '99', 'attendance': '78', 'pta': 65, 'project2': '99', 'id': '55527760'},
   '32548926': {'exam1': '9', 'project1': '7', 'classrecap': '77', 'homework': '98', 'exam2': '1', 'attendance': '43', 'project2': '86', 'id': '32548926'}}

generateReport(d)
with open('gradebook.txt') as f: 
  x = f.read() 
  print(x)

它适用于购物车项目,但我做了更多R& D并尝试弄清楚我是如何制作它但我可以在xml中添加以下块

<layout version="0.1.0">
 <checkout_cart_index>
    <reference name="checkout.cart">
        <action method="setTemplate"><template>itemdeletion/cart.phtml</template></action>      
        <action method="addItemRender"><type>simple</type><block>checkout/cart_item_renderer</block><template>itemdeletion/cart/item/default.phtml</template></action>
        <action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>itemdeletion/cart/item/default.phtml</template></action>
         <action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>itemdeletion/cart/item/default.phtml</template></action>
    </reference>
 </checkout_cart_index>
</layout>

但仍无效。请帮我解决这个问题。     提前致谢

0 个答案:

没有答案