Posts Tagged ‘canReturnItemToStock’

I got this error while credit memo ..
So i have placed this two function in
Mage/Adminhtml/Block/Sales/Items/Abstract.php

Here is the functions..
public function canReturnItemToStock($item=null) {
$canReturnToStock = Mage::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_CAN_SUBTRACT);
if (!is_null($item)) {
if (!$item->hasCanReturnToStock()) {
$product = Mage::getModel(‘catalog/product’)->load($item->getOrderItem()->getProductId());
if ( $product->getId() && $product->getStockItem()->getManageStock() ) {
$item->setCanReturnToStock(true);
}
else {
$item->setCanReturnToStock(false);
}
}
$canReturnToStock = $item->getCanReturnToStock();
}
return $canReturnToStock;
}

public function canParentReturnToStock($item = null)
{
$canReturnToStock = Mage::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_CAN_SUBTRACT);
if (!is_null($item)) {
if ( $item->getCreditmemo()->getOrder()->hasCanReturnToStock() ) {
$canReturnToStock = $item->getCreditmemo()->getOrder()->getCanReturnToStock();
}
} elseif ( $this->getOrder()->hasCanReturnToStock() ) {
$canReturnToStock = $this->getOrder()->getCanReturnToStock();
}
return $canReturnToStock;
}

I hope this will helpful….
Bijal Bhavsar 🙂

Advertisements