1: <?php
2: /**
3: * Magento
4: *
5: * NOTICE OF LICENSE
6: *
7: * This source file is subject to the Open Software License (OSL 3.0)
8: * that is bundled with this package in the file LICENSE.txt.
9: * It is also available through the world-wide-web at this URL:
10: * http://opensource.org/licenses/osl-3.0.php
11: * If you did not receive a copy of the license and are unable to
12: * obtain it through the world-wide-web, please send an email
13: * to license@magentocommerce.com so we can send you a copy immediately.
14: *
15: * DISCLAIMER
16: *
17: * Do not edit or add to this file if you wish to upgrade Magento to newer
18: * versions in the future. If you wish to customize Magento for your
19: * needs please refer to http://www.magentocommerce.com for more information.
20: *
21: * @category Mage
22: * @package Mage_Sales
23: * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24: * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25: */
26:
27:
28: /**
29: * Enter description here ...
30: *
31: * @method Mage_Sales_Model_Resource_Quote_Address_Item _getResource()
32: * @method Mage_Sales_Model_Resource_Quote_Address_Item getResource()
33: * @method int getParentItemId()
34: * @method Mage_Sales_Model_Quote_Address_Item setParentItemId(int $value)
35: * @method int getQuoteAddressId()
36: * @method Mage_Sales_Model_Quote_Address_Item setQuoteAddressId(int $value)
37: * @method int getQuoteItemId()
38: * @method Mage_Sales_Model_Quote_Address_Item setQuoteItemId(int $value)
39: * @method string getCreatedAt()
40: * @method Mage_Sales_Model_Quote_Address_Item setCreatedAt(string $value)
41: * @method string getUpdatedAt()
42: * @method Mage_Sales_Model_Quote_Address_Item setUpdatedAt(string $value)
43: * @method string getAppliedRuleIds()
44: * @method Mage_Sales_Model_Quote_Address_Item setAppliedRuleIds(string $value)
45: * @method string getAdditionalData()
46: * @method Mage_Sales_Model_Quote_Address_Item setAdditionalData(string $value)
47: * @method float getWeight()
48: * @method Mage_Sales_Model_Quote_Address_Item setWeight(float $value)
49: * @method Mage_Sales_Model_Quote_Address_Item setQty(float $value)
50: * @method float getDiscountAmount()
51: * @method Mage_Sales_Model_Quote_Address_Item setDiscountAmount(float $value)
52: * @method Mage_Sales_Model_Quote_Address_Item setTaxAmount(float $value)
53: * @method float getRowTotal()
54: * @method Mage_Sales_Model_Quote_Address_Item setRowTotal(float $value)
55: * @method float getBaseRowTotal()
56: * @method Mage_Sales_Model_Quote_Address_Item setBaseRowTotal(float $value)
57: * @method float getRowTotalWithDiscount()
58: * @method Mage_Sales_Model_Quote_Address_Item setRowTotalWithDiscount(float $value)
59: * @method float getBaseDiscountAmount()
60: * @method Mage_Sales_Model_Quote_Address_Item setBaseDiscountAmount(float $value)
61: * @method Mage_Sales_Model_Quote_Address_Item setBaseTaxAmount(float $value)
62: * @method float getRowWeight()
63: * @method Mage_Sales_Model_Quote_Address_Item setRowWeight(float $value)
64: * @method int getProductId()
65: * @method Mage_Sales_Model_Quote_Address_Item setProductId(int $value)
66: * @method int getSuperProductId()
67: * @method Mage_Sales_Model_Quote_Address_Item setSuperProductId(int $value)
68: * @method int getParentProductId()
69: * @method Mage_Sales_Model_Quote_Address_Item setParentProductId(int $value)
70: * @method string getSku()
71: * @method Mage_Sales_Model_Quote_Address_Item setSku(string $value)
72: * @method string getImage()
73: * @method Mage_Sales_Model_Quote_Address_Item setImage(string $value)
74: * @method string getName()
75: * @method Mage_Sales_Model_Quote_Address_Item setName(string $value)
76: * @method string getDescription()
77: * @method Mage_Sales_Model_Quote_Address_Item setDescription(string $value)
78: * @method int getFreeShipping()
79: * @method Mage_Sales_Model_Quote_Address_Item setFreeShipping(int $value)
80: * @method int getIsQtyDecimal()
81: * @method Mage_Sales_Model_Quote_Address_Item setIsQtyDecimal(int $value)
82: * @method float getDiscountPercent()
83: * @method Mage_Sales_Model_Quote_Address_Item setDiscountPercent(float $value)
84: * @method int getNoDiscount()
85: * @method Mage_Sales_Model_Quote_Address_Item setNoDiscount(int $value)
86: * @method float getTaxPercent()
87: * @method Mage_Sales_Model_Quote_Address_Item setTaxPercent(float $value)
88: * @method float getBasePrice()
89: * @method Mage_Sales_Model_Quote_Address_Item setBasePrice(float $value)
90: * @method float getBaseCost()
91: * @method Mage_Sales_Model_Quote_Address_Item setBaseCost(float $value)
92: * @method float getPriceInclTax()
93: * @method Mage_Sales_Model_Quote_Address_Item setPriceInclTax(float $value)
94: * @method float getBasePriceInclTax()
95: * @method Mage_Sales_Model_Quote_Address_Item setBasePriceInclTax(float $value)
96: * @method float getRowTotalInclTax()
97: * @method Mage_Sales_Model_Quote_Address_Item setRowTotalInclTax(float $value)
98: * @method float getBaseRowTotalInclTax()
99: * @method Mage_Sales_Model_Quote_Address_Item setBaseRowTotalInclTax(float $value)
100: * @method int getGiftMessageId()
101: * @method Mage_Sales_Model_Quote_Address_Item setGiftMessageId(int $value)
102: * @method float getHiddenTaxAmount()
103: * @method Mage_Sales_Model_Quote_Address_Item setHiddenTaxAmount(float $value)
104: * @method float getBaseHiddenTaxAmount()
105: * @method Mage_Sales_Model_Quote_Address_Item setBaseHiddenTaxAmount(float $value)
106: *
107: * @category Mage
108: * @package Mage_Sales
109: * @author Magento Core Team <core@magentocommerce.com>
110: */
111: class Mage_Sales_Model_Quote_Address_Item extends Mage_Sales_Model_Quote_Item_Abstract
112: {
113: /**
114: * Quote address model object
115: *
116: * @var Mage_Sales_Model_Quote_Address
117: */
118: protected $_address;
119: protected $_quote;
120:
121: protected function _construct()
122: {
123: $this->_init('sales/quote_address_item');
124: }
125:
126: protected function _beforeSave()
127: {
128: parent::_beforeSave();
129: if ($this->getAddress()) {
130: $this->setQuoteAddressId($this->getAddress()->getId());
131: }
132: return $this;
133: }
134:
135: /**
136: * Declare address model
137: *
138: * @param Mage_Sales_Model_Quote_Address $address
139: * @return Mage_Sales_Model_Quote_Address_Item
140: */
141: public function setAddress(Mage_Sales_Model_Quote_Address $address)
142: {
143: $this->_address = $address;
144: $this->_quote = $address->getQuote();
145: return $this;
146: }
147:
148: /**
149: * Retrieve address model
150: *
151: * @return Mage_Sales_Model_Quote_Address
152: */
153: public function getAddress()
154: {
155: return $this->_address;
156: }
157:
158: /**
159: * Retrieve quote model instance
160: *
161: * @return Mage_Sales_Model_Quote
162: */
163: public function getQuote()
164: {
165: return $this->_quote;
166: }
167:
168:
169: public function importQuoteItem(Mage_Sales_Model_Quote_Item $quoteItem)
170: {
171: $this->_quote = $quoteItem->getQuote();
172: $this->setQuoteItem($quoteItem)
173: ->setQuoteItemId($quoteItem->getId())
174: ->setProductId($quoteItem->getProductId())
175: ->setProduct($quoteItem->getProduct())
176: ->setSku($quoteItem->getSku())
177: ->setName($quoteItem->getName())
178: ->setDescription($quoteItem->getDescription())
179: ->setWeight($quoteItem->getWeight())
180: ->setPrice($quoteItem->getPrice())
181: ->setCost($quoteItem->getCost());
182:
183: if (!$this->hasQty()) {
184: $this->setQty($quoteItem->getQty());
185: }
186: $this->setQuoteItemImported(true);
187: return $this;
188: }
189:
190: public function getOptionBycode($code)
191: {
192: if ($this->getQuoteItem()) {
193: return $this->getQuoteItem()->getOptionBycode($code);
194: }
195: return null;
196: }
197: }
198: