Magento-在贷项凭单上指示是否将物品退还库存 [英] Magento - Indicate on credit memo whether items were returned to stock

查看:36
本文介绍了Magento-在贷项凭单上指示是否将物品退还库存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要自定义贷项通知单页面以存储是否将某项目退还到库存中.

I need to customize the Credit Memo page to store whether or not an item was returned to stock.

我在以下位置确定了观察者:

I've identified the Observer in:

app\code\core\Mage\CatalogInventory\Model\Observer.php
refundOrderInventory()

,当管理员提交带有返回库存"复选框的贷项通知单时被触发.所以我知道我可以添加自己的观察者来编写/保存某些内容.

which gets triggered when the admin submits the credit memo with the 'Return to Stock' checkbox ticked. So I know I can add my own observer to write/save something.

但是我无法弄清楚如何在贷项凭证产品项中添加额外的属性.

But I cant figure out how to add an extra attribute to the Credit Memo product items.

有人可以给我一些指示吗?

Could anyone give me some pointers?

更新:我还可以通过编辑添加额外的返回库存表格单元格:

UPDATE: I can also add the extra Returned to Stock table cell by editing:

app\design\adminhtml\default\default\template\sales\order\creditmemo\view\items.phtml

app\design\adminhtml\default\default\template\sales\order\creditmemo\view\items\renderer\default.phtml

给我这个:

我已经硬编码了您在其中看到的是"值.我需要找到一种使它成为可写/可读的贷记产品属性的方法.

I've hardcoded the "YES" value you see in there. I need to find some way of making this a writeable/readable credit-memo product attribute.

推荐答案

您将需要在安装脚本中将属性和列添加到creditmemo项目实体.确保设置类为 Mage_Eav_Model_Entity_Setup ,因为 Mage_Core_Model_Resource_Setup 中没有 addAttribute()函数.

You will want to add the attribute and column to your creditmemo item entity, in an install script. Make sure to have your setup class to be Mage_Eav_Model_Entity_Setup as there is no addAttribute() function in Mage_Core_Model_Resource_Setup.

$installer->addAttribute('creditmemo_item', 'returned_to_stock', array('type' => 'int', 'grid' => true, 'source' => 'adminhtml/system_config_source_yesno'));
$installer->getConnection()->addColumn($installer->getTable('sales/creditmemo_item'), 'returned_to_stock', 'TINYINT(1) unsigned DEFAULT 0');

然后,在您的观察者中(请不要修改您在此处列出的观察者),将值设置为true,就像这样(我只是复制了您列出的函数,并对其进行了少许修改以说明我的观点):

Then, in your observer (please don't modify the observer you listed there), set the value to be true, like so (I just copied the function you listed, and modified it slightly to demonstrate my point):

public function refundOrderInventory($observer)
{
    $creditmemo = $observer->getEvent()->getCreditmemo();
    $items = array();
    foreach ($creditmemo->getAllItems() as $item) {
        $return = false;
        if ($item->hasBackToStock()) {
            if ($item->getBackToStock() && $item->getQty()) {
                $return = true;
            }
        } elseif (Mage::helper('cataloginventory')->isAutoReturnEnabled()) {
            $return = true;
        }
        if ($return) {
            $item->setReturnedToStock(1);
        }
    }
}

这篇关于Magento-在贷项凭单上指示是否将物品退还库存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆