Mage_Catalog_Model_Product_Option_Value Class Reference

Inheritance diagram for Mage_Catalog_Model_Product_Option_Value:

Mage_Core_Model_Abstract Varien_Object

List of all members.

Public Member Functions

 addValue ($value)
 getValues ()
 setValues ($values)
 unsetValues ()
 setOption (Mage_Catalog_Model_Product_Option $option)
 unsetOption ()
 getOption ()
 setProduct ($product)
 getProduct ()
 saveValues ()
 getPrice ($flag=false)
 getValuesCollection (Mage_Catalog_Model_Product_Option $option)
 getValuesByOption ($optionIds, $option_id, $store_id)
 deleteValue ($option_id)
 deleteValues ($option_type_id)
 prepareValueForDuplicate ()
 duplicate ($oldOptionId, $newOptionId)

Protected Member Functions

 _construct ()

Protected Attributes

 $_values = array()
 $_product
 $_option


Detailed Description

Definition at line 34 of file Value.php.


Member Function Documentation

_construct (  )  [protected]

Enter description here...

Reimplemented from Varien_Object.

Definition at line 42 of file Value.php.

00043     {
00044         $this->_init('catalog/product_option_value');
00045     }

addValue ( value  ) 

Definition at line 47 of file Value.php.

00048     {
00049         $this->_values[] = $value;
00050         return $this;
00051     }

deleteValue ( option_id  ) 

Definition at line 172 of file Value.php.

00173     {
00174         $this->getResource()->deleteValue($option_id);
00175         return $this;
00176     }

deleteValues ( option_type_id  ) 

Definition at line 178 of file Value.php.

00179     {
00180         $this->getResource()->deleteValues($option_type_id);
00181         return $this;
00182     }

duplicate ( oldOptionId,
newOptionId 
)

Duplicate product options value

Parameters:
int $oldOptionId
int $newOptionId
Returns:
Mage_Catalog_Model_Product_Option_Value

Definition at line 204 of file Value.php.

00205     {
00206         $this->getResource()->duplicate($this, $oldOptionId, $newOptionId);
00207         return $this;
00208     }

getOption (  ) 

Enter description here...

Returns:
Mage_Catalog_Model_Product_Option

Definition at line 87 of file Value.php.

00088     {
00089         return $this->_option;
00090     }

getPrice ( flag = false  ) 

Return price. If $flag is true and price is percent return converted percent to price

Parameters:
bool $flag
Returns:
decimal

Definition at line 138 of file Value.php.

00139     {
00140         if ($flag && $this->getPriceType() == 'percent') {
00141             $basePrice = $this->getOption()->getProduct()->getFinalPrice();
00142             $price = $basePrice*($this->_getData('price')/100);
00143             return $price;
00144         }
00145         return $this->_getData('price');
00146     }

getProduct (  ) 

Definition at line 98 of file Value.php.

00099     {
00100         if (is_null($this->_product)) {
00101             $this->_product = $this->getOption()->getProduct();
00102         }
00103         return $this->_product;
00104     }

getValues (  ) 

Definition at line 53 of file Value.php.

00054     {
00055         return $this->_values;
00056     }

getValuesByOption ( optionIds,
option_id,
store_id 
)

Definition at line 163 of file Value.php.

00164     {
00165         $collection = Mage::getResourceModel('catalog/product_option_value_collection')
00166             ->addFieldToFilter('option_id', $option_id)
00167             ->getValuesByOption($optionIds, $store_id);
00168 
00169         return $collection;
00170     }

getValuesCollection ( Mage_Catalog_Model_Product_Option option  ) 

Enter description here...

Parameters:
Mage_Catalog_Model_Product_Option $option
Returns:
Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Option_Value_Collection

Definition at line 154 of file Value.php.

00155     {
00156         $collection = Mage::getResourceModel('catalog/product_option_value_collection')
00157             ->addFieldToFilter('option_id', $option->getId())
00158             ->getValues($option->getStoreId());
00159 
00160         return $collection;
00161     }

prepareValueForDuplicate (  ) 

Prepare array of option values for duplicate

Returns:
array

Definition at line 189 of file Value.php.

00190     {
00191         $this->setOptionId(null);
00192         $this->setOptionTypeId(null);
00193 
00194         return $this->__toArray();
00195     }

saveValues (  ) 

Definition at line 106 of file Value.php.

00107     {
00108         foreach ($this->getValues() as $value) {
00109             $this->setData($value)
00110                 ->setData('option_id', $this->getOption()->getId())
00111                 ->setData('store_id', $this->getOption()->getStoreId());
00112 
00113             if ($this->getData('option_type_id') == '-1') {//change to 0
00114                 $this->unsetData('option_type_id');
00115             } else {
00116                 $this->setId($this->getData('option_type_id'));
00117             }
00118 
00119             if ($this->getData('is_delete') == '1') {
00120                 if ($this->getId()) {
00121                     $this->deleteValues($this->getId());
00122                     $this->delete();
00123                 }
00124             } else {
00125                 $this->save();
00126             }
00127         }//eof foreach()
00128         return $this;
00129     }

setOption ( Mage_Catalog_Model_Product_Option option  ) 

Definition at line 70 of file Value.php.

00071     {
00072         $this->_option = $option;
00073         return $this;
00074     }

setProduct ( product  ) 

Definition at line 92 of file Value.php.

00093     {
00094         $this->_product = $product;
00095         return $this;
00096     }

setValues ( values  ) 

Definition at line 58 of file Value.php.

00059     {
00060         $this->_values = $values;
00061         return $this;
00062     }

unsetOption (  ) 

Definition at line 76 of file Value.php.

00077     {
00078         $this->_option = null;
00079         return $this;
00080     }

unsetValues (  ) 

Definition at line 64 of file Value.php.

00065     {
00066         $this->_values = array();
00067         return $this;
00068     }


Member Data Documentation

$_option [protected]

Definition at line 40 of file Value.php.

$_product [protected]

Definition at line 38 of file Value.php.

$_values = array() [protected]

Definition at line 36 of file Value.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:23:41 2009 for Magento by  doxygen 1.5.8