Mage_Catalog_Model_Product_Type Class Reference

List of all members.

Static Public Member Functions

static factory ($product, $singleton=false)
static priceFactory ($productType)
static getOptionArray ()
static getAllOption ()
static getAllOptions ()
static getOptions ()
static getOptionText ($optionId)
static getTypes ()
static getCompositeTypes ()

Public Attributes

const TYPE_SIMPLE = 'simple'
const TYPE_BUNDLE = 'bundle'
const TYPE_CONFIGURABLE = 'configurable'
const TYPE_GROUPED = 'grouped'
const TYPE_VIRTUAL = 'virtual'
const DEFAULT_TYPE = 'simple'
const DEFAULT_TYPE_MODEL = 'catalog/product_type_simple'
const DEFAULT_PRICE_MODEL = 'catalog/product_type_price'

Static Protected Attributes

static $_types
static $_compositeTypes
static $_priceModels


Detailed Description

Definition at line 34 of file Type.php.


Member Function Documentation

static factory ( product,
singleton = false 
) [static]

Product type instance factory

Parameters:
Mage_Catalog_Model_Product $product
bool $singleton
Returns:
Mage_Catalog_Model_Product_Type_Abstract

Definition at line 60 of file Type.php.

00061     {
00062         $types = self::getTypes();
00063 
00064         if (!empty($types[$product->getTypeId()]['model'])) {
00065             $typeModelName = $types[$product->getTypeId()]['model'];
00066         } else {
00067             $typeModelName = self::DEFAULT_TYPE_MODEL;
00068         }
00069 
00070         if ($singleton === true) {
00071             $typeModel = Mage::getSingleton($typeModelName);
00072         }
00073         else {
00074             $typeModel = Mage::getModel($typeModelName);
00075             $typeModel->setProduct($product);
00076         }
00077         $typeModel->setConfig($types[$product->getTypeId()]);
00078         return $typeModel;
00079     }

static getAllOption (  )  [static]

Definition at line 115 of file Type.php.

00116     {
00117         $options = self::getOptionArray();
00118         array_unshift($options, array('value'=>'', 'label'=>''));
00119         return $options;
00120     }

static getAllOptions (  )  [static]

Definition at line 122 of file Type.php.

00123     {
00124         $res = array();
00125         $res[] = array('value'=>'', 'label'=>'');
00126         foreach (self::getOptionArray() as $index => $value) {
00127             $res[] = array(
00128                'value' => $index,
00129                'label' => $value
00130             );
00131         }
00132         return $res;
00133     }

static getCompositeTypes (  )  [static]

Return composite product type Ids

Returns:
array

Definition at line 167 of file Type.php.

00168     {
00169         if (is_null(self::$_compositeTypes)) {
00170             self::$_compositeTypes = array();
00171             $types = self::getTypes();
00172             foreach ($types as $typeId=>$typeInfo) {
00173                 if (array_key_exists('composite', $typeInfo) && $typeInfo['composite']) {
00174                     self::$_compositeTypes[] = $typeId;
00175                 }
00176             }
00177         }
00178         return self::$_compositeTypes;
00179     }

static getOptionArray (  )  [static]

Definition at line 105 of file Type.php.

00106     {
00107         $options = array();
00108         foreach(self::getTypes() as $typeId=>$type) {
00109             $options[$typeId] = $type['label'];
00110         }
00111 
00112         return $options;
00113     }

static getOptions (  )  [static]

Definition at line 135 of file Type.php.

00136     {
00137         $res = array();
00138         foreach (self::getOptionArray() as $index => $value) {
00139             $res[] = array(
00140                'value' => $index,
00141                'label' => $value
00142             );
00143         }
00144         return $res;
00145     }

static getOptionText ( optionId  )  [static]

Definition at line 147 of file Type.php.

00148     {
00149         $options = self::getOptionArray();
00150         return isset($options[$optionId]) ? $options[$optionId] : null;
00151     }

static getTypes (  )  [static]

Definition at line 153 of file Type.php.

00154     {
00155         if (is_null(self::$_types)) {
00156             self::$_types = Mage::getConfig()->getNode('global/catalog/product/type')->asArray();
00157         }
00158 
00159         return self::$_types;
00160     }

static priceFactory ( productType  )  [static]

Product type price model factory

Parameters:
string $productType
Returns:
Mage_Catalog_Model_Product_Type_Price

Definition at line 87 of file Type.php.

00088     {
00089         if (isset(self::$_priceModels[$productType])) {
00090             return self::$_priceModels[$productType];
00091         }
00092 
00093         $types = self::getTypes();
00094 
00095         if (!empty($types[$productType]['price_model'])) {
00096             $priceModelName = $types[$productType]['price_model'];
00097         } else {
00098             $priceModelName = self::DEFAULT_PRICE_MODEL;
00099         }
00100 
00101         self::$_priceModels[$productType] = Mage::getModel($priceModelName);
00102         return self::$_priceModels[$productType];
00103     }


Member Data Documentation

$_compositeTypes [static, protected]

Definition at line 50 of file Type.php.

$_priceModels [static, protected]

Definition at line 51 of file Type.php.

$_types [static, protected]

Definition at line 49 of file Type.php.

const DEFAULT_PRICE_MODEL = 'catalog/product_type_price'

Definition at line 47 of file Type.php.

const DEFAULT_TYPE = 'simple'

Definition at line 45 of file Type.php.

const DEFAULT_TYPE_MODEL = 'catalog/product_type_simple'

Definition at line 46 of file Type.php.

const TYPE_BUNDLE = 'bundle'

Definition at line 40 of file Type.php.

const TYPE_CONFIGURABLE = 'configurable'

Definition at line 41 of file Type.php.

const TYPE_GROUPED = 'grouped'

Definition at line 42 of file Type.php.

const TYPE_SIMPLE = 'simple'

Available product types

Definition at line 39 of file Type.php.

const TYPE_VIRTUAL = 'virtual'

Definition at line 43 of file Type.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