如何在 magento 中获取与发票相关的产品列表?

发布于 2024-10-06 10:41:57 字数 336 浏览 0 评论 0原文

我正在尝试按字母顺序排列 magento 网站后端发票上列出的项目。

我可以访问用于在后端显示这些项目的 Mage_Adminhtml_Block_Sales_Order_Invoice_View_Items 对象。

有什么方法可以使用此对象来获取产品 sku 列表并重新订购这些商品吗?

编辑:

下面是收集要在视图中显示的对象的代码行。我想我需要在此之前对物品进行排序 -

<?php $_items = $this->getInvoice()->getAllItems() ?>

I am trying to alphabetize the items listed on an invoice in the backend of a magento site.

I have access to the Mage_Adminhtml_Block_Sales_Order_Invoice_View_Items object used to display these items in the backend.

Is there any way I can use this object to get a list of product skus and reorder these items?

Edit:

Here's the line of code that's gathering the objects for display in the view. I imagine I'd need to get the items sorted before this point –

<?php $_items = $this->getInvoice()->getAllItems() ?>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

耶耶耶 2024-10-13 10:41:57

您应该将处理程序附加到事件“sales_order_invoice_item_collection_load_before”。从事件中获取集合对象并附加此函数

$invoiceObject->addAttributeToSort('sku', 'desc')

You should attach you handler on event "sales_order_invoice_item_collection_load_before". Get collection object from event and attach this function

$invoiceObject->addAttributeToSort('sku', 'desc')
没︽人懂的悲伤 2024-10-13 10:41:57

你可以试试这个:

$this->getInvoice()->getItemsCollection()->addAttributeToSort('sku', 'desc')

you can try this:

$this->getInvoice()->getItemsCollection()->addAttributeToSort('sku', 'desc')
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文