00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 class Mage_Sales_Model_Quote_Address_Item extends Mage_Sales_Model_Quote_Item_Abstract
00029 {
00030
00031
00032
00033
00034
00035 protected $_address;
00036 protected $_quote;
00037
00038 protected function _construct()
00039 {
00040 $this->_init('sales/quote_address_item');
00041 }
00042
00043 protected function _beforeSave()
00044 {
00045 parent::_beforeSave();
00046 if ($this->getAddress()) {
00047 $this->setQuoteAddressId($this->getAddress()->getId());
00048 }
00049 return $this;
00050 }
00051
00052
00053
00054
00055
00056
00057
00058 public function setAddress(Mage_Sales_Model_Quote_Address $address)
00059 {
00060 $this->_address = $address;
00061 $this->_quote = $address->getQuote();
00062 return $this;
00063 }
00064
00065
00066
00067
00068
00069
00070 public function getAddress()
00071 {
00072 return $this->_address;
00073 }
00074
00075
00076
00077
00078
00079
00080 public function getQuote()
00081 {
00082 return $this->_quote;
00083 }
00084
00085
00086 public function importQuoteItem(Mage_Sales_Model_Quote_Item $quoteItem)
00087 {
00088 $this->_quote = $quoteItem->getQuote();
00089 $this->setQuoteItem($quoteItem)
00090 ->setQuoteItemId($quoteItem->getId())
00091 ->setProductId($quoteItem->getProductId())
00092 ->setProduct($quoteItem->getProduct())
00093 ->setSku($quoteItem->getSku())
00094 ->setName($quoteItem->getName())
00095 ->setDescription($quoteItem->getDescription())
00096 ->setWeight($quoteItem->getWeight())
00097 ->setPrice($quoteItem->getPrice())
00098 ->setCost($quoteItem->getCost());
00099
00100 if (!$this->hasQty()) {
00101 $this->setQty($quoteItem->getQty());
00102 }
00103 $this->setQuoteItemImported(true);
00104 return $this;
00105 }
00106
00107 public function getOptionBycode($code)
00108 {
00109 if ($this->getQuoteItem()) {
00110 return $this->getQuoteItem()->getOptionBycode($code);
00111 }
00112 return null;
00113 }
00114 }