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_Catalog 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 * Item option model 00029 * 00030 * @category Mage 00031 * @package Mage_Sales 00032 * @author Magento Core Team <core@magentocommerce.com> 00033 */ 00034 class Mage_Sales_Model_Quote_Item_Option extends Mage_Core_Model_Abstract 00035 { 00036 protected $_item; 00037 protected $_product; 00038 00039 /** 00040 * Initialize resource model 00041 */ 00042 protected function _construct() 00043 { 00044 $this->_init('sales/quote_item_option'); 00045 } 00046 00047 /** 00048 * Set quote item 00049 * 00050 * @param Mage_Sales_Model_Quote_Item $item 00051 * @return Mage_Sales_Model_Quote_Item_Option 00052 */ 00053 public function setItem($item) 00054 { 00055 $this->setItemId($item->getId()); 00056 $this->_item = $item; 00057 return $this; 00058 } 00059 00060 /** 00061 * Get option item 00062 * 00063 * @return Mage_Sales_Model_Quote_Item 00064 */ 00065 public function getItem() 00066 { 00067 return $this->_item; 00068 } 00069 00070 /** 00071 * Set option product 00072 * 00073 * @param Mage_Catalog_Model_Product $product 00074 * @return Mage_Sales_Model_Quote_Item_Option 00075 */ 00076 public function setProduct($product) 00077 { 00078 $this->setProductId($product->getId()); 00079 $this->_product = $product; 00080 return $this; 00081 } 00082 00083 /** 00084 * Get option product 00085 * 00086 * @return Mage_Catalog_Model_Product 00087 */ 00088 public function getProduct() 00089 { 00090 return $this->_product; 00091 } 00092 00093 /** 00094 * Initialize item identifier before save data 00095 * 00096 * @return Mage_Sales_Model_Quote_Item_Option 00097 */ 00098 protected function _beforeSave() 00099 { 00100 if ($this->getItem()) { 00101 $this->setItemId($this->getItem()->getId()); 00102 } 00103 return parent::_beforeSave(); 00104 } 00105 00106 /** 00107 * Clone option object 00108 * 00109 * @return Mage_Sales_Model_Quote_Item_Option 00110 */ 00111 public function __clone() 00112 { 00113 $this->setId(null); 00114 $this->_item = null; 00115 return $this; 00116 } 00117 }