00001 <?php 00002 /** 00003 * Magento 00004 * 00005 * NOTICE OF LICENSE 00006 * 00007 * This source file is subject to the Open Software License (OSL 3.0) 00008 * that is bundled with this package in the file LICENSE.txt. 00009 * It is also available through the world-wide-web at this URL: 00010 * http://opensource.org/licenses/osl-3.0.php 00011 * If you did not receive a copy of the license and are unable to 00012 * obtain it through the world-wide-web, please send an email 00013 * to license@magentocommerce.com so we can send you a copy immediately. 00014 * 00015 * DISCLAIMER 00016 * 00017 * Do not edit or add to this file if you wish to upgrade Magento to newer 00018 * versions in the future. If you wish to customize Magento for your 00019 * needs please refer to http://www.magentocommerce.com for more information. 00020 * 00021 * @category Mage 00022 * @package Mage_Adminhtml 00023 * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) 00024 * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 00025 */ 00026 00027 /** 00028 * Product inventory data 00029 * 00030 * @author Magento Core Team <core@magentocommerce.com> 00031 */ 00032 class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Inventory extends Mage_Adminhtml_Block_Widget 00033 { 00034 public function __construct() 00035 { 00036 parent::__construct(); 00037 $this->setTemplate('catalog/product/tab/inventory.phtml'); 00038 } 00039 00040 public function getBackordersOption() 00041 { 00042 return Mage::getSingleton('cataloginventory/source_backorders')->toOptionArray(); 00043 } 00044 00045 /** 00046 * Retrieve stock option array 00047 * 00048 * @return array 00049 */ 00050 public function getStockOption() 00051 { 00052 return Mage::getSingleton('cataloginventory/source_stock')->toOptionArray(); 00053 } 00054 00055 public function getProduct() 00056 { 00057 return Mage::registry('product'); 00058 } 00059 00060 /** 00061 * Retrieve Catalog Inventory Stock Item Model 00062 * 00063 * @return Mage_CatalogInventory_Model_Stock_Item 00064 */ 00065 public function getStockItem() 00066 { 00067 return Mage::registry('product')->getStockItem(); 00068 } 00069 00070 public function isConfigurable() 00071 { 00072 return Mage::registry('product')->isConfigurable(); 00073 } 00074 00075 public function getFieldValue($field) 00076 { 00077 if ($this->getStockItem()) { 00078 return $this->getStockItem()->getDataUsingMethod($field); 00079 } 00080 00081 return Mage::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_ITEM . $field); 00082 } 00083 00084 public function getConfigFieldValue($field) 00085 { 00086 if ($this->getStockItem()) { 00087 if ($this->getStockItem()->getData('use_config_' . $field) == 0) { 00088 return $this->getStockItem()->getData($field); 00089 } 00090 } 00091 00092 return Mage::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_ITEM . $field); 00093 } 00094 00095 public function getDefaultConfigValue($field) 00096 { 00097 return Mage::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_ITEM . $field); 00098 } 00099 00100 /** 00101 * Is readonly stock 00102 * 00103 * @return boolean 00104 */ 00105 public function isReadonly() 00106 { 00107 return $this->getProduct()->getInventoryReadonly(); 00108 } 00109 00110 public function isNew() 00111 { 00112 if (Mage::registry('product')->getId()) { 00113 return false; 00114 } 00115 return true; 00116 } 00117 00118 public function getFieldSuffix() 00119 { 00120 return 'product'; 00121 } 00122 }