All Classes Namespaces Files Functions Variables Pages
Mage_Catalog_Model_Product Class Reference
Inheritance diagram for Mage_Catalog_Model_Product:
Mage_Catalog_Model_Abstract Mage_Core_Model_Abstract Varien_Object Mage_ImportExport_Model_Import_Proxy_Product

Public Member Functions

 getStoreId ()
 
 getResourceCollection ()
 
 getUrlModel ()
 
 validate ()
 
 getName ()
 
 getPrice ()
 
 setPriceCalculation ($calculate=true)
 
 getTypeId ()
 
 getStatus ()
 
 getTypeInstance ($singleton=false)
 
 setTypeInstance ($instance, $singleton=false)
 
 getLinkInstance ()
 
 getIdBySku ($sku)
 
 getCategoryId ()
 
 getCategory ()
 
 setCategoryIds ($ids)
 
 getCategoryIds ()
 
 getCategoryCollection ()
 
 getWebsiteIds ()
 
 getStoreIds ()
 
 getAttributes ($groupId=null, $skipSuper=false)
 
 canAffectOptions ($value=null)
 
 cleanCache ()
 
 getPriceModel ()
 
 getGroupPrice ()
 
 getTierPrice ($qty=null)
 
 getTierPriceCount ()
 
 getFormatedTierPrice ($qty=null)
 
 getFormatedPrice ()
 
 setFinalPrice ($price)
 
 getFinalPrice ($qty=null)
 
 getCalculatedFinalPrice ()
 
 getMinimalPrice ()
 
 getSpecialPrice ()
 
 getSpecialFromDate ()
 
 getSpecialToDate ()
 
 getRelatedProducts ()
 
 getRelatedProductIds ()
 
 getRelatedProductCollection ()
 
 getRelatedLinkCollection ()
 
 getUpSellProducts ()
 
 getUpSellProductIds ()
 
 getUpSellProductCollection ()
 
 getUpSellLinkCollection ()
 
 getCrossSellProducts ()
 
 getCrossSellProductIds ()
 
 getCrossSellProductCollection ()
 
 getCrossSellLinkCollection ()
 
 getGroupedLinkCollection ()
 
 getMediaAttributes ()
 
 getMediaGalleryImages ()
 
 addImageToMediaGallery ($file, $mediaAttribute=null, $move=false, $exclude=true)
 
 getMediaConfig ()
 
 duplicate ()
 
 isSuperGroup ()
 
 isSuperConfig ()
 
 isGrouped ()
 
 isConfigurable ()
 
 isSuper ()
 
 getVisibleInCatalogStatuses ()
 
 getVisibleStatuses ()
 
 isVisibleInCatalog ()
 
 getVisibleInSiteVisibilities ()
 
 isVisibleInSiteVisibility ()
 
 isDuplicable ()
 
 setIsDuplicable ($value)
 
 isSalable ()
 
 isAvailable ()
 
 getIsSalable ()
 
 isVirtual ()
 
 isRecurring ()
 
 isSaleable ()
 
 isInStock ()
 
 getAttributeText ($attributeCode)
 
 getCustomDesignDate ()
 
 getProductUrl ($useSid=null)
 
 getUrlInStore ($params=array())
 
 formatUrlKey ($str)
 
 getUrlPath ($category=null)
 
 addAttributeUpdate ($code, $value, $store)
 
 toArray (array $arrAttributes=array())
 
 fromArray ($data)
 
 loadParentProductIds ()
 
 delete ()
 
 getRequestPath ()
 
 getGiftMessageAvailable ()
 
 getRatingSummary ()
 
 isComposite ()
 
 canConfigure ()
 
 getSku ()
 
 getWeight ()
 
 getOptionInstance ()
 
 getProductOptionsCollection ()
 
 addOption (Mage_Catalog_Model_Product_Option $option)
 
 getOptionById ($optionId)
 
 getOptions ()
 
 getIsVirtual ()
 
 addCustomOption ($code, $value, $product=null)
 
 setCustomOptions (array $options)
 
 getCustomOptions ()
 
 getCustomOption ($code)
 
 hasCustomOptions ()
 
 canBeShowInCategory ($categoryId)
 
 getAvailableInCategories ()
 
 getDefaultAttributeSetId ()
 
 getImageUrl ()
 
 getSmallImageUrl ($width=88, $height=77)
 
 getThumbnailUrl ($width=75, $height=75)
 
 getReservedAttributes ()
 
 isReservedAttribute ($attribute)
 
 setOrigData ($key=null, $data=null)
 
 reset ()
 
 getCacheIdTags ()
 
 isProductsHasSku (array $productIds)
 
 processBuyRequest (Varien_Object $buyRequest)
 
 getPreconfiguredValues ()
 
 prepareCustomOptions ()
 
 getProductEntitiesInfo ($columns=null)
 
 isDisabled ()
 
- Public Member Functions inherited from Mage_Catalog_Model_Abstract
 lockAttribute ($attributeCode)
 
 unlockAttribute ($attributeCode)
 
 unlockAttributes ()
 
 getLockedAttributes ()
 
 hasLockedAttributes ()
 
 isLockedAttribute ($attributeCode)
 
 setData ($key, $value=null)
 
 unsetData ($key=null)
 
 getResourceCollection ()
 
 loadByAttribute ($attribute, $value, $additionalAttributes= '*')
 
 getStore ()
 
 getWebsiteStoreIds ()
 
 setAttributeDefaultValue ($attributeCode, $value)
 
 getAttributeDefaultValue ($attributeCode)
 
 setExistsStoreValueFlag ($attributeCode)
 
 getExistsStoreValueFlag ($attributeCode)
 
 isDeleteable ()
 
 setIsDeleteable ($value)
 
 isReadonly ()
 
 setIsReadonly ($value)
 
- Public Member Functions inherited from Mage_Core_Model_Abstract
 getIdFieldName ()
 
 getId ()
 
 setId ($id)
 
 getResourceName ()
 
 getResourceCollection ()
 
 getCollection ()
 
 load ($id, $field=null)
 
 afterLoad ()
 
 save ()
 
 afterCommitCallback ()
 
 isObjectNew ($flag=null)
 
 getCacheTags ()
 
 getCacheIdTags ()
 
 cleanModelCache ()
 
 delete ()
 
 getResource ()
 
 getEntityId ()
 
 clearInstance ()
 
- Public Member Functions inherited from Varien_Object
 __construct ()
 
 isDeleted ($isDeleted=null)
 
 hasDataChanges ()
 
 setIdFieldName ($name)
 
 getIdFieldName ()
 
 getId ()
 
 setId ($value)
 
 addData (array $arr)
 
 setData ($key, $value=null)
 
 unsetData ($key=null)
 
 unsetOldData ($key=null)
 
 getData ($key='', $index=null)
 
 setDataUsingMethod ($key, $args=array())
 
 getDataUsingMethod ($key, $args=null)
 
 getDataSetDefault ($key, $default)
 
 hasData ($key='')
 
 __toArray (array $arrAttributes=array())
 
 toArray (array $arrAttributes=array())
 
 toXml (array $arrAttributes=array(), $rootName= 'item', $addOpenTag=false, $addCdata=true)
 
 toJson (array $arrAttributes=array())
 
 toString ($format='')
 
 __call ($method, $args)
 
 __get ($var)
 
 __set ($var, $value)
 
 isEmpty ()
 
 serialize ($attributes=array(), $valueSeparator='=', $fieldSeparator=' ', $quote='"')
 
 getOrigData ($key=null)
 
 setOrigData ($key=null, $data=null)
 
 dataHasChangedFor ($field)
 
 setDataChanges ($value)
 
 debug ($data=null, &$objects=array())
 
 offsetSet ($offset, $value)
 
 offsetExists ($offset)
 
 offsetUnset ($offset)
 
 offsetGet ($offset)
 
 isDirty ($field=null)
 
 flagDirty ($field, $flag=true)
 

Public Attributes

const ENTITY = 'catalog_product'
 
const CACHE_TAG = 'catalog_product'
 
- Public Attributes inherited from Mage_Catalog_Model_Abstract
const DEFAULT_STORE_ID = 0
 

Protected Member Functions

 _construct ()
 
 _initOldFieldsMap ()
 
 _beforeSave ()
 
 _afterSave ()
 
 _beforeDelete ()
 
 _afterDeleteCommit ()
 
 _afterLoad ()
 
 _getResource ()
 
 _getImageHelper ()
 
 _clearReferences ()
 
 _clearData ()
 
 _clearOptionReferences ()
 
- Protected Member Functions inherited from Mage_Catalog_Model_Abstract
 _beforeSave ()
 
- Protected Member Functions inherited from Mage_Core_Model_Abstract
 _init ($resourceModel)
 
 _setResourceModel ($resourceName, $resourceCollectionName=null)
 
 _getResource ()
 
 _getEventData ()
 
 _beforeLoad ($id, $field=null)
 
 _afterLoad ()
 
 _hasModelChanged ()
 
 _afterSaveCommit ()
 
 _beforeSave ()
 
 _afterSave ()
 
 _beforeDelete ()
 
 _protectFromNonAdmin ()
 
 _afterDelete ()
 
 _afterDeleteCommit ()
 
 _clearReferences ()
 
 _clearData ()
 
- Protected Member Functions inherited from Varien_Object
 _addFullNames ()
 
 _initOldFieldsMap ()
 
 _prepareSyncFieldsMap ()
 
 _construct ()
 
 _getData ($key)
 
 _prepareArray (&$arr, array $elements=array())
 
 __toXml (array $arrAttributes=array(), $rootName= 'item', $addOpenTag=false, $addCdata=true)
 
 __toJson (array $arrAttributes=array())
 
 _underscore ($name)
 
 _camelize ($name)
 

Protected Attributes

 $_cacheTag = 'catalog_product'
 
 $_eventPrefix = 'catalog_product'
 
 $_eventObject = 'product'
 
 $_canAffectOptions = false
 
 $_typeInstance = null
 
 $_typeInstanceSingleton = null
 
 $_linkInstance
 
 $_customOptions = array()
 
 $_urlModel = null
 
 $_errors = array()
 
 $_optionInstance
 
 $_options = array()
 
 $_reservedAttributes
 
 $_isDuplicable = true
 
 $_calculatePrice = true
 
- Protected Attributes inherited from Mage_Catalog_Model_Abstract
 $_defaultValues = array()
 
 $_storeValuesFlags = array()
 
 $_lockedAttributes = array()
 
 $_isDeleteable = true
 
 $_isReadonly = false
 
- Protected Attributes inherited from Mage_Core_Model_Abstract
 $_eventPrefix = 'core_abstract'
 
 $_eventObject = 'object'
 
 $_resourceName
 
 $_resource
 
 $_resourceCollectionName
 
 $_cacheTag = false
 
 $_dataSaveAllowed = true
 
 $_isObjectNew = null
 
- Protected Attributes inherited from Varien_Object
 $_data = array()
 
 $_hasDataChanges = false
 
 $_origData
 
 $_idFieldName = null
 
 $_isDeleted = false
 
 $_oldFieldsMap = array()
 
 $_syncFieldsMap = array()
 

Static Protected Attributes

static $_url
 
static $_urlRewrite
 

Detailed Description

Definition at line 37 of file Product.php.

Member Function Documentation

_afterDeleteCommit ( )
protected

Init indexing process after product delete commit

Returns
Mage_Catalog_Model_Product

Definition at line 577 of file Product.php.

References Mage\getSingleton(), and Mage_Index_Model_Event\TYPE_DELETE.

{
parent::_afterDeleteCommit();
Mage::getSingleton('index/indexer')->indexEvents(
);
}
_afterLoad ( )
protected

Load product options if they exists

Returns
Mage_Catalog_Model_Product

Load product options

Definition at line 590 of file Product.php.

References addOption(), and getProductOptionsCollection().

{
parent::_afterLoad();
if ($this->getHasOptions()) {
foreach ($this->getProductOptionsCollection() as $option) {
$option->setProduct($this);
$this->addOption($option);
}
}
return $this;
}
_afterSave ( )
protected

Saving product type related data and init index

Returns
Mage_Catalog_Model_Product

Product Options

Definition at line 537 of file Product.php.

References $result, getLinkInstance(), getOptionInstance(), Mage\getSingleton(), getTypeInstance(), and Mage_Index_Model_Event\TYPE_SAVE.

{
$this->getLinkInstance()->saveProductRelations($this);
$this->getTypeInstance(true)->save($this);
$this->getOptionInstance()->setProduct($this)
->saveOptions();
$result = parent::_afterSave();
Mage::getSingleton('index/indexer')->processEntityAction(
$this, self::ENTITY, Mage_Index_Model_Event::TYPE_SAVE
);
return $result;
}
_beforeDelete ( )
protected

Clear chache related with product and protect delete from not admin Register indexing event before delete product

Returns
Mage_Catalog_Model_Product

Definition at line 562 of file Product.php.

References Mage_Core_Model_Abstract\_protectFromNonAdmin(), cleanCache(), Mage\getSingleton(), and Mage_Index_Model_Event\TYPE_DELETE.

{
$this->cleanCache();
Mage::getSingleton('index/indexer')->logEvent(
);
return parent::_beforeDelete();
}
_beforeSave ( )
protected

Check product options and type options and save them, too

$this->_canAffectOptions - set by type instance only $this->getCanSaveCustomOptions() - set either in controller when "Custom Options" ajax tab is loaded, or in type instance as well

Set true, if any Set false, ONLY if options have been affected by Options tab and Type instance tab

Definition at line 463 of file Product.php.

References $options, canAffectOptions(), cleanCache(), getOptionInstance(), getOptions(), and getTypeInstance().

{
$this->cleanCache();
$this->setTypeHasOptions(false);
$this->setTypeHasRequiredOptions(false);
$this->getTypeInstance(true)->beforeSave($this);
$hasOptions = false;
$hasRequiredOptions = false;
$this->canAffectOptions($this->_canAffectOptions && $this->getCanSaveCustomOptions());
if ($this->getCanSaveCustomOptions()) {
$options = $this->getProductOptions();
if (is_array($options)) {
$this->setIsCustomOptionChanged(true);
foreach ($this->getProductOptions() as $option) {
$this->getOptionInstance()->addOption($option);
if ((!isset($option['is_delete'])) || $option['is_delete'] != '1') {
$hasOptions = true;
}
}
foreach ($this->getOptionInstance()->getOptions() as $option) {
if ($option['is_require'] == '1') {
$hasRequiredOptions = true;
break;
}
}
}
}
if ($hasOptions || (bool)$this->getTypeHasOptions()) {
$this->setHasOptions(true);
if ($hasRequiredOptions || (bool)$this->getTypeHasRequiredOptions()) {
$this->setRequiredOptions(true);
} elseif ($this->canAffectOptions()) {
$this->setRequiredOptions(false);
}
} elseif ($this->canAffectOptions()) {
$this->setHasOptions(false);
$this->setRequiredOptions(false);
}
parent::_beforeSave();
}
_clearData ( )
protected

Clearing product's data

Returns
Mage_Catalog_Model_Product

Definition at line 2001 of file Product.php.

References $data, array, Mage_Catalog_Model_Abstract\setData(), and setOrigData().

{
foreach ($this->_data as $data){
if (is_object($data) && method_exists($data, 'reset')){
$data->reset();
}
}
$this->setData(array());
$this->setOrigData();
$this->_customOptions = array();
$this->_optionInstance = null;
$this->_options = array();
$this->_canAffectOptions = false;
$this->_errors = array();
return $this;
}
_clearOptionReferences ( )
protected

Clearing references to product from product's options

Returns
Mage_Catalog_Model_Product

unload product options

Definition at line 2025 of file Product.php.

{
if (!empty($this->_options)) {
foreach ($this->_options as $key => $option) {
$option->setProduct();
$option->clearInstance();
}
}
return $this;
}
_clearReferences ( )
protected

Clearing references on product

Returns
Mage_Catalog_Model_Product

Definition at line 1990 of file Product.php.

References _clearOptionReferences().

{
return $this;
}
_construct ( )
protected

Initialize resources

Definition at line 115 of file Product.php.

References Mage_Core_Model_Abstract\_init().

{
$this->_init('catalog/product');
}
_getImageHelper ( )
protected

Return Catalog Product Image helper instance

Returns
Mage_Catalog_Helper_Image

Definition at line 1781 of file Product.php.

References Mage\helper().

{
return Mage::helper('catalog/image');
}
_getResource ( )
protected

Retrieve resource instance wrapper

Returns
Mage_Catalog_Model_Resource_Eav_Mysql4_Product

Definition at line 610 of file Product.php.

{
return parent::_getResource();
}
_initOldFieldsMap ( )
protected

Init mapping array of short fields to its full names

Returns
Varien_Object

Definition at line 126 of file Product.php.

References Mage\helper().

{
$this->_oldFieldsMap = Mage::helper('catalog')->getOldFieldMap();
return $this;
}
addAttributeUpdate (   $code,
  $value,
  $store 
)

Save current attribute with code $code and assign new value

Parameters
string$codeAttribute code
mixed$valueNew attribute value
int$storeStore ID
Returns
void

Definition at line 1459 of file Product.php.

References $store, Varien_Object\getData(), Mage_Core_Model_Abstract\getResource(), getStoreId(), and Mage_Catalog_Model_Abstract\setData().

{
$oldValue = $this->getData($code);
$oldStore = $this->getStoreId();
$this->setData($code, $value);
$this->setStoreId($store);
$this->getResource()->saveAttribute($this, $code);
$this->setData($code, $oldValue);
$this->setStoreId($oldStore);
}
addCustomOption (   $code,
  $value,
  $product = null 
)

Add custom option information to product

Parameters
string$codeOption code
mixed$valueValue of the option
int$productProduct ID
Returns
Mage_Catalog_Model_Product

Definition at line 1682 of file Product.php.

References array, and Mage\getModel().

{
$product = $product ? $product : $this;
$option = Mage::getModel('catalog/product_configuration_item_option')
->addData(array(
'product_id'=> $product->getId(),
'product' => $product,
'code' => $code,
'value' => $value,
));
$this->_customOptions[$code] = $option;
return $this;
}
addImageToMediaGallery (   $file,
  $mediaAttribute = null,
  $move = false,
  $exclude = true 
)

Add image to media gallery

Parameters
string$filefile path of image in file system
string | array$mediaAttributecode of attribute with type 'media_image', leave blank if image should be only in gallery
boolean$moveif true, it will move source file
boolean$excludemark image as disabled in product page view
Returns
Mage_Catalog_Model_Product

Definition at line 1038 of file Product.php.

References $attributes, and getTypeInstance().

{
$attributes = $this->getTypeInstance(true)->getSetAttributes($this);
if (!isset($attributes['media_gallery'])) {
return $this;
}
$mediaGalleryAttribute = $attributes['media_gallery'];
/* @var $mediaGalleryAttribute Mage_Catalog_Model_Resource_Eav_Attribute */
$mediaGalleryAttribute->getBackend()->addImage($this, $file, $mediaAttribute, $move, $exclude);
return $this;
}
addOption ( Mage_Catalog_Model_Product_Option  $option)

Add option to array of product options

Parameters
Mage_Catalog_Model_Product_Option$option
Returns
Mage_Catalog_Model_Product

Definition at line 1633 of file Product.php.

References Mage_Core_Model_Abstract\getId().

{
$this->_options[$option->getId()] = $option;
return $this;
}
canAffectOptions (   $value = null)

Check/set if options can be affected when saving product If value specified, it will be set.

Parameters
bool$value
Returns
bool

Definition at line 524 of file Product.php.

References $_canAffectOptions.

{
if (null !== $value) {
$this->_canAffectOptions = (bool)$value;
}
}
canBeShowInCategory (   $categoryId)

Check availability display product in category

Parameters
int$categoryId
Returns
bool

Definition at line 1751 of file Product.php.

References _getResource().

{
return $this->_getResource()->canBeShowInCategory($this, $categoryId);
}
canConfigure ( )

Check if product can be configured

Returns
bool

Definition at line 1575 of file Product.php.

References $options, getOptions(), and getTypeInstance().

{
$options = $this->getOptions();
return !empty($options) || $this->getTypeInstance(true)->canConfigure($this);
}
cleanCache ( )

Clear cache related with product id

Returns
Mage_Catalog_Model_Product

Definition at line 620 of file Product.php.

References Mage\app(), and Mage_Core_Model_Abstract\getId().

{
Mage::app()->cleanCache('catalog_product_'.$this->getId());
return $this;
}
delete ( )

Delete product

Returns
Mage_Catalog_Model_Product

Definition at line 1523 of file Product.php.

References array, and Mage\dispatchEvent().

{
parent::delete();
Mage::dispatchEvent($this->_eventPrefix.'_delete_after_done', array($this->_eventObject=>$this));
return $this;
}
duplicate ( )

Create duplicate

Returns
Mage_Catalog_Model_Product

Definition at line 1065 of file Product.php.

References $attributes, $data, Mage\app(), array, Mage\dispatchEvent(), getAttributes(), getCategoryIds(), getCrossSellLinkCollection(), Varien_Object\getData(), getGroupedLinkCollection(), Mage_Core_Model_Abstract\getId(), getLinkInstance(), Mage\getModel(), getOptionInstance(), getRelatedLinkCollection(), Mage_Core_Model_Abstract\getResource(), Mage_Catalog_Model_Abstract\getStore(), getUpSellLinkCollection(), getWebsiteIds(), and Mage_Catalog_Model_Product_Status\STATUS_DISABLED.

{
$this->getWebsiteIds();
$this->getCategoryIds();
/* @var $newProduct Mage_Catalog_Model_Product */
$newProduct = Mage::getModel('catalog/product')->setData($this->getData())
->setIsDuplicate(true)
->setOriginalId($this->getId())
->setSku(null)
->setCreatedAt(null)
->setUpdatedAt(null)
->setId(null)
->setStoreId(Mage::app()->getStore()->getId());
'catalog_model_product_duplicate',
array('current_product' => $this, 'new_product' => $newProduct)
);
/* Prepare Related*/
$data = array();
$this->getLinkInstance()->useRelatedLinks();
foreach ($this->getLinkInstance()->getAttributes() as $_attribute) {
if (isset($_attribute['code'])) {
$attributes[] = $_attribute['code'];
}
}
foreach ($this->getRelatedLinkCollection() as $_link) {
$data[$_link->getLinkedProductId()] = $_link->toArray($attributes);
}
$newProduct->setRelatedLinkData($data);
/* Prepare UpSell*/
$data = array();
$this->getLinkInstance()->useUpSellLinks();
foreach ($this->getLinkInstance()->getAttributes() as $_attribute) {
if (isset($_attribute['code'])) {
$attributes[] = $_attribute['code'];
}
}
foreach ($this->getUpSellLinkCollection() as $_link) {
$data[$_link->getLinkedProductId()] = $_link->toArray($attributes);
}
$newProduct->setUpSellLinkData($data);
/* Prepare Cross Sell */
$data = array();
$this->getLinkInstance()->useCrossSellLinks();
foreach ($this->getLinkInstance()->getAttributes() as $_attribute) {
if (isset($_attribute['code'])) {
$attributes[] = $_attribute['code'];
}
}
foreach ($this->getCrossSellLinkCollection() as $_link) {
$data[$_link->getLinkedProductId()] = $_link->toArray($attributes);
}
$newProduct->setCrossSellLinkData($data);
/* Prepare Grouped */
$data = array();
$this->getLinkInstance()->useGroupedLinks();
foreach ($this->getLinkInstance()->getAttributes() as $_attribute) {
if (isset($_attribute['code'])) {
$attributes[] = $_attribute['code'];
}
}
foreach ($this->getGroupedLinkCollection() as $_link) {
$data[$_link->getLinkedProductId()] = $_link->toArray($attributes);
}
$newProduct->setGroupedLinkData($data);
$newProduct->save();
$this->getOptionInstance()->duplicate($this->getId(), $newProduct->getId());
$this->getResource()->duplicate($this->getId(), $newProduct->getId());
// TODO - duplicate product on all stores of the websites it is associated with
/*if ($storeIds = $this->getWebsiteIds()) {
foreach ($storeIds as $storeId) {
$this->setStoreId($storeId)
->load($this->getId());
$newProduct->setData($this->getData())
->setSku(null)
->setStatus(Mage_Catalog_Model_Product_Status::STATUS_DISABLED)
->setId($newId)
->save();
}
}*/
return $newProduct;
}
formatUrlKey (   $str)

Formats URL key

Parameters
$strURL
Returns
string

Definition at line 1435 of file Product.php.

References getUrlModel().

{
return $this->getUrlModel()->formatUrlKey($str);
}
fromArray (   $data)

Same as setData(), but also initiates the stock item (if it is there)

Parameters
array$dataArray to form the object from
Returns
Mage_Catalog_Model_Product

Definition at line 1494 of file Product.php.

References $data, Mage\getModel(), Mage\helper(), and Mage_Catalog_Model_Abstract\setData().

{
if (isset($data['stock_item'])) {
if (Mage::helper('catalog')->isModuleEnabled('Mage_CatalogInventory')) {
$stockItem = Mage::getModel('cataloginventory/stock_item')
->setData($data['stock_item'])
->setProduct($this);
$this->setStockItem($stockItem);
}
unset($data['stock_item']);
}
$this->setData($data);
return $this;
}
getAttributes (   $groupId = null,
  $skipSuper = false 
)

Retrieve product attributes if $groupId is null - retrieve all product attributes

Parameters
int$groupIdRetrieve attributes of the specified group
bool$skipSuperNot used
Returns
array

Definition at line 443 of file Product.php.

References $attribute, $attributes, array, and getTypeInstance().

{
$productAttributes = $this->getTypeInstance(true)->getEditableAttributes($this);
if ($groupId) {
foreach ($productAttributes as $attribute) {
if ($attribute->isInGroup($this->getAttributeSetId(), $groupId)) {
}
}
} else {
$attributes = $productAttributes;
}
return $attributes;
}
getAttributeText (   $attributeCode)

Get attribute text by its code

Parameters
$attributeCodeCode of the attribute
Returns
string

Definition at line 1385 of file Product.php.

References Varien_Object\getData(), and Mage_Core_Model_Abstract\getResource().

{
return $this->getResource()
->getAttribute($attributeCode)
->getSource()
->getOptionText($this->getData($attributeCode));
}
getAvailableInCategories ( )

Retrieve category ids where product is available

Returns
array

Definition at line 1761 of file Product.php.

References _getResource().

{
return $this->_getResource()->getAvailableInCategories($this);
}
getCacheIdTags ( )

Get cahce tags associated with object id

Returns
array

Definition at line 1893 of file Product.php.

References Mage_Catalog_Model_Category\CACHE_TAG, and getCategoryIds().

{
$tags = parent::getCacheIdTags();
$affectedCategoryIds = $this->getAffectedCategoryIds();
if (!$affectedCategoryIds) {
$affectedCategoryIds = $this->getCategoryIds();
}
foreach ($affectedCategoryIds as $categoryId) {
$tags[] = Mage_Catalog_Model_Category::CACHE_TAG.'_'.$categoryId;
}
return $tags;
}
getCalculatedFinalPrice ( )

Returns calculated final price

Returns
float

Definition at line 724 of file Product.php.

References Varien_Object\_getData().

{
return $this->_getData('calculated_final_price');
}
getCategory ( )

Retrieve product category

Returns
Mage_Catalog_Model_Category

Definition at line 335 of file Product.php.

References $category, getCategoryId(), Varien_Object\getData(), and Mage\getModel().

{
$category = $this->getData('category');
if (is_null($category) && $this->getCategoryId()) {
$category = Mage::getModel('catalog/category')->load($this->getCategoryId());
$this->setCategory($category);
}
return $category;
}
getCategoryCollection ( )

Retrieve product categories

Returns
Varien_Data_Collection

Definition at line 396 of file Product.php.

References _getResource().

{
return $this->_getResource()->getCategoryCollection($this);
}
getCategoryId ( )

Retrieve product category id

Returns
int

Definition at line 322 of file Product.php.

References $category, and Mage\registry().

{
if ($category = Mage::registry('current_category')) {
return $category->getId();
}
return false;
}
getCategoryIds ( )

Retrieve assigned category Ids

Returns
array

Definition at line 373 of file Product.php.

References $ids, Varien_Object\_getData(), _getResource(), array, Varien_Object\hasData(), Mage_Catalog_Model_Abstract\isLockedAttribute(), Mage_Catalog_Model_Abstract\lockAttribute(), Mage_Catalog_Model_Abstract\setData(), and Mage_Catalog_Model_Abstract\unlockAttribute().

{
if (! $this->hasData('category_ids')) {
$wasLocked = false;
if ($this->isLockedAttribute('category_ids')) {
$wasLocked = true;
$this->unlockAttribute('category_ids');
}
$ids = $this->_getResource()->getCategoryIds($this);
$this->setData('category_ids', $ids);
if ($wasLocked) {
$this->lockAttribute('category_ids');
}
}
return (array) $this->_getData('category_ids');
}
getCrossSellLinkCollection ( )

Retrieve collection cross sell link

Returns
Mage_Catalog_Model_Resource_Product_Link_Collection

Definition at line 955 of file Product.php.

References getLinkInstance().

{
$collection = $this->getLinkInstance()->useCrossSellLinks()
->getLinkCollection();
$collection->setProduct($this);
$collection->addLinkTypeIdFilter();
$collection->addProductIdFilter();
$collection->joinAttributes();
return $collection;
}
getCrossSellProductCollection ( )

Retrieve collection cross sell product

Returns
Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Link_Product_Collection

Definition at line 941 of file Product.php.

References getLinkInstance().

{
$collection = $this->getLinkInstance()->useCrossSellLinks()
->getProductCollection()
->setIsStrongMode();
$collection->setProduct($this);
return $collection;
}
getCrossSellProductIds ( )

Retrieve cross sell products identifiers

Returns
array

Definition at line 924 of file Product.php.

References $ids, array, getCrossSellProducts(), and Varien_Object\getData().

{
if (!$this->hasCrossSellProductIds()) {
$ids = array();
foreach ($this->getCrossSellProducts() as $product) {
$ids[] = $product->getId();
}
$this->setCrossSellProductIds($ids);
}
return $this->getData('cross_sell_product_ids');
}
getCrossSellProducts ( )

Retrieve array of cross sell products

Returns
array

Definition at line 907 of file Product.php.

References array, getCrossSellProductCollection(), and Varien_Object\getData().

{
if (!$this->hasCrossSellProducts()) {
$products = array();
foreach ($this->getCrossSellProductCollection() as $product) {
$products[] = $product;
}
$this->setCrossSellProducts($products);
}
return $this->getData('cross_sell_products');
}
getCustomDesignDate ( )

Returns array with dates for custom design

Returns
array

Definition at line 1398 of file Product.php.

References $result, array, and Varien_Object\getData().

{
$result['from'] = $this->getData('custom_design_from');
$result['to'] = $this->getData('custom_design_to');
return $result;
}
getCustomOption (   $code)

Get product custom option info

Parameters
string$code
Returns
array

Definition at line 1723 of file Product.php.

{
if (isset($this->_customOptions[$code])) {
return $this->_customOptions[$code];
}
return null;
}
getCustomOptions ( )

Get all custom options of the product

Returns
array

Definition at line 1712 of file Product.php.

References $_customOptions.

{
}
getDefaultAttributeSetId ( )

Retrieve default attribute set id

Returns
int

Definition at line 1771 of file Product.php.

References Mage_Core_Model_Abstract\getResource().

{
return $this->getResource()->getEntityType()->getDefaultAttributeSetId();
}
getFinalPrice (   $qty = null)

Get product final price

Parameters
double$qty
Returns
double

Definition at line 710 of file Product.php.

References Varien_Object\_getData(), and getPriceModel().

{
$price = $this->_getData('final_price');
if ($price !== null) {
return $price;
}
return $this->getPriceModel()->getFinalPrice($qty, $this);
}
getFormatedPrice ( )

Get formated by currency product price

Returns
array || double

Definition at line 683 of file Product.php.

References getPriceModel().

{
return $this->getPriceModel()->getFormatedPrice($this);
}
getFormatedTierPrice (   $qty = null)

Get formated by currency tier price

Parameters
double$qty
Returns
array || double

Definition at line 673 of file Product.php.

References getPriceModel().

{
return $this->getPriceModel()->getFormatedTierPrice($qty, $this);
}
getGiftMessageAvailable ( )

Custom function for other modules

Returns
string

Definition at line 1545 of file Product.php.

References Varien_Object\_getData().

{
return $this->_getData('gift_message_available');
}
getGroupedLinkCollection ( )

Retrieve collection grouped link

Returns
Mage_Catalog_Model_Resource_Product_Link_Collection

Definition at line 971 of file Product.php.

References getLinkInstance().

{
$collection = $this->getLinkInstance()->useGroupedLinks()
->getLinkCollection();
$collection->setProduct($this);
$collection->addLinkTypeIdFilter();
$collection->addProductIdFilter();
$collection->joinAttributes();
return $collection;
}
getGroupPrice ( )

Get product group price

Returns
float

Definition at line 641 of file Product.php.

References getPriceModel().

{
return $this->getPriceModel()->getGroupPrice($this);
}
getIdBySku (   $sku)

Retrive product id by sku

Parameters
string$sku
Returns
integer

Definition at line 312 of file Product.php.

References _getResource().

{
return $this->_getResource()->getIdBySku($sku);
}
getImageUrl ( )

Return re-sized image URL

Deprecated:
since 1.1.5
Returns
string

Definition at line 1792 of file Product.php.

References _getImageHelper().

{
return (string)$this->_getImageHelper()->init($this, 'image')->resize(265);
}
getIsSalable ( )

Is product salable detecting by product type

Returns
bool

Definition at line 1325 of file Product.php.

References array, Varien_Object\getData(), getTypeInstance(), Varien_Object\hasData(), and isSalable().

{
$productType = $this->getTypeInstance(true);
if (is_callable(array($productType, 'getIsSalable'))) {
return $productType->getIsSalable($this);
}
if ($this->hasData('is_salable')) {
return $this->getData('is_salable');
}
return $this->isSalable();
}
getIsVirtual ( )

Retrieve is a virtual product

Returns
bool

Definition at line 1669 of file Product.php.

References getTypeInstance().

{
return $this->getTypeInstance(true)->isVirtual($this);
}
getLinkInstance ( )

Retrieve link instance

Returns
Mage_Catalog_Model_Product_Link

Definition at line 298 of file Product.php.

References $_linkInstance, and Mage\getSingleton().

{
if (!$this->_linkInstance) {
$this->_linkInstance = Mage::getSingleton('catalog/product_link');
}
}
getMediaAttributes ( )

Retrive attributes for media gallery

Returns
array

Definition at line 990 of file Product.php.

References $attribute, array, getAttributes(), and Varien_Object\getData().

{
if (!$this->hasMediaAttributes()) {
$mediaAttributes = array();
foreach ($this->getAttributes() as $attribute) {
if($attribute->getFrontend()->getInputType() == 'media_image') {
$mediaAttributes[$attribute->getAttributeCode()] = $attribute;
}
}
$this->setMediaAttributes($mediaAttributes);
}
return $this->getData('media_attributes');
}
getMediaConfig ( )

Retrive product media config

Returns
Mage_Catalog_Model_Product_Media_Config

Definition at line 1055 of file Product.php.

References Mage\getSingleton().

{
return Mage::getSingleton('catalog/product_media_config');
}
getMediaGalleryImages ( )

Retrive media gallery images

Returns
Varien_Data_Collection

Definition at line 1009 of file Product.php.

References Varien_Object\getData(), getMediaConfig(), Varien_Object\hasData(), and Mage_Catalog_Model_Abstract\setData().

{
if(!$this->hasData('media_gallery_images') && is_array($this->getMediaGallery('images'))) {
$images = new Varien_Data_Collection();
foreach ($this->getMediaGallery('images') as $image) {
if ($image['disabled']) {
continue;
}
$image['url'] = $this->getMediaConfig()->getMediaUrl($image['file']);
$image['id'] = isset($image['value_id']) ? $image['value_id'] : null;
$image['path'] = $this->getMediaConfig()->getMediaPath($image['file']);
$images->addItem(new Varien_Object($image));
}
$this->setData('media_gallery_images', $images);
}
return $this->getData('media_gallery_images');
}
getMinimalPrice ( )

Returns minimal price

Returns
float

Definition at line 734 of file Product.php.

References Varien_Object\_getData().

{
return max($this->_getData('minimal_price'), 0);
}
getName ( )

Get product name

Returns
string

Definition at line 198 of file Product.php.

References Varien_Object\_getData().

{
return $this->_getData('name');
}
getOptionById (   $optionId)

Get option from options array of product by given option id

Parameters
int$optionId
Returns
Mage_Catalog_Model_Product_Option | null

Definition at line 1645 of file Product.php.

{
if (isset($this->_options[$optionId])) {
return $this->_options[$optionId];
}
return null;
}
getOptionInstance ( )

Retrieve option instance

Returns
Mage_Catalog_Model_Product_Option

Definition at line 1606 of file Product.php.

References $_optionInstance, and Mage\getSingleton().

{
if (!$this->_optionInstance) {
$this->_optionInstance = Mage::getSingleton('catalog/product_option');
}
}
getOptions ( )

Get all options of product

Returns
array

Definition at line 1659 of file Product.php.

References $_options.

{
}
getPreconfiguredValues ( )

Get preconfigured values from product

Returns
Varien_Object

Definition at line 1958 of file Product.php.

References Varien_Object\getData().

{
$preconfiguredValues = $this->getData('preconfigured_values');
if (!$preconfiguredValues) {
$preconfiguredValues = new Varien_Object();
}
return $preconfiguredValues;
}
getPrice ( )

Get product price throught type instance

Returns
unknown

Definition at line 208 of file Product.php.

References Varien_Object\getData(), and getPriceModel().

{
if ($this->_calculatePrice || !$this->getData('price')) {
return $this->getPriceModel()->getPrice($this);
} else {
return $this->getData('price');
}
}
getPriceModel ( )

Get product price model

Returns
Mage_Catalog_Model_Product_Type_Price

Definition at line 631 of file Product.php.

References Mage\getSingleton(), and getTypeId().

{
return Mage::getSingleton('catalog/product_type')->priceFactory($this->getTypeId());
}
getProductEntitiesInfo (   $columns = null)

Retrieve product entities info as array

Parameters
string | array$columnsOne or several columns
Returns
array

Definition at line 2046 of file Product.php.

References $columns, and _getResource().

{
return $this->_getResource()->getProductEntitiesInfo($columns);
}
getProductOptionsCollection ( )

Retrieve options collection of product

Returns
Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Option_Collection

Definition at line 1619 of file Product.php.

References getOptionInstance().

{
$collection = $this->getOptionInstance()
->getProductOptionCollection($this);
return $collection;
}
getProductUrl (   $useSid = null)

Retrieve Product URL

Parameters
bool$useSid
Returns
string

Definition at line 1413 of file Product.php.

References getUrlModel().

{
return $this->getUrlModel()->getProductUrl($this, $useSid);
}
getRatingSummary ( )

Returns rating summary

Returns
mixed

Definition at line 1555 of file Product.php.

References Varien_Object\_getData().

{
return $this->_getData('rating_summary');
}
getRelatedLinkCollection ( )

Retrieve collection related link

Returns
Mage_Catalog_Model_Resource_Product_Link_Collection

Definition at line 827 of file Product.php.

References getLinkInstance().

{
$collection = $this->getLinkInstance()->useRelatedLinks()
->getLinkCollection();
$collection->setProduct($this);
$collection->addLinkTypeIdFilter();
$collection->addProductIdFilter();
$collection->joinAttributes();
return $collection;
}
getRelatedProductCollection ( )

Retrieve collection related product

Returns
Mage_Catalog_Model_Resource_Product_Link_Product_Collection

Definition at line 813 of file Product.php.

References getLinkInstance().

{
$collection = $this->getLinkInstance()->useRelatedLinks()
->getProductCollection()
->setIsStrongMode();
$collection->setProduct($this);
return $collection;
}
getRelatedProductIds ( )

Retrieve related products identifiers

Returns
array

Definition at line 796 of file Product.php.

References $ids, array, Varien_Object\getData(), and getRelatedProducts().

{
if (!$this->hasRelatedProductIds()) {
$ids = array();
foreach ($this->getRelatedProducts() as $product) {
$ids[] = $product->getId();
}
$this->setRelatedProductIds($ids);
}
return $this->getData('related_product_ids');
}
getRelatedProducts ( )

Retrieve array of related roducts

Returns
array

Definition at line 778 of file Product.php.

References array, Varien_Object\getData(), and getRelatedProductCollection().

{
if (!$this->hasRelatedProducts()) {
$products = array();
$collection = $this->getRelatedProductCollection();
foreach ($collection as $product) {
$products[] = $product;
}
$this->setRelatedProducts($products);
}
return $this->getData('related_products');
}
getRequestPath ( )

Returns request path

Returns
string

Definition at line 1535 of file Product.php.

References Varien_Object\_getData().

{
return $this->_getData('request_path');
}
getReservedAttributes ( )

Returns system reserved attribute codes

Returns
array Reserved attribute names

Definition at line 1828 of file Product.php.

References $_reservedAttributes, and array.

{
if ($this->_reservedAttributes === null) {
$_reserved = array('position');
$methods = get_class_methods(__CLASS__);
foreach ($methods as $method) {
if (preg_match('/^get([A-Z]{1}.+)/', $method, $matches)) {
$method = $matches[1];
$tmp = strtolower(preg_replace('/(.)([A-Z])/', "$1_$2", $method));
$_reserved[] = $tmp;
}
}
$_allowed = array(
'type_id','calculated_final_price','request_path','rating_summary'
);
$this->_reservedAttributes = array_diff($_reserved, $_allowed);
}
}
getResourceCollection ( )

Get collection instance

Returns
object

Definition at line 150 of file Product.php.

References __(), Mage\getResourceModel(), getStoreId(), Mage\helper(), and Mage\throwException().

{
if (empty($this->_resourceCollectionName)) {
Mage::throwException(Mage::helper('catalog')->__('The model collection resource name is not defined.'));
}
$collection = Mage::getResourceModel($this->_resourceCollectionName);
$collection->setStoreId($this->getStoreId());
return $collection;
}
getSku ( )

Retrieve sku through type instance

Returns
string

Definition at line 1586 of file Product.php.

References getTypeInstance().

{
return $this->getTypeInstance(true)->getSku($this);
}
getSmallImageUrl (   $width = 88,
  $height = 77 
)

Return re-sized small image URL

Deprecated:
since 1.1.5
Parameters
int$width
int$height
Returns
string

Definition at line 1805 of file Product.php.

References _getImageHelper().

{
return (string)$this->_getImageHelper()->init($this, 'small_image')->resize($width, $height);
}
getSpecialFromDate ( )

Returns starting date of the special price

Returns
mixed

Definition at line 754 of file Product.php.

References Varien_Object\_getData().

{
return $this->_getData('special_from_date');
}
getSpecialPrice ( )

Returns special price

Returns
float

Definition at line 744 of file Product.php.

References Varien_Object\_getData().

{
return $this->_getData('special_price');
}
getSpecialToDate ( )

Returns end date of the special price

Returns
mixed

Definition at line 764 of file Product.php.

References Varien_Object\_getData().

{
return $this->_getData('special_to_date');
}
getStatus ( )

Get product status

Returns
int

Definition at line 243 of file Product.php.

References Varien_Object\_getData(), Mage_Catalog_Model_Abstract\setData(), and Mage_Catalog_Model_Product_Status\STATUS_ENABLED.

{
if (is_null($this->_getData('status'))) {
}
return $this->_getData('status');
}
getStoreId ( )

Retrieve Store Id

Returns
int

Definition at line 137 of file Product.php.

References Mage\app(), Varien_Object\getData(), and Varien_Object\hasData().

{
if ($this->hasData('store_id')) {
return $this->getData('store_id');
}
return Mage::app()->getStore()->getId();
}
getStoreIds ( )

Get all sore ids where product is presented

Returns
array

Definition at line 420 of file Product.php.

References $storeIds, $websiteIds, Mage\app(), array, Varien_Object\getData(), and getWebsiteIds().

{
if (!$this->hasStoreIds()) {
if ($websiteIds = $this->getWebsiteIds()) {
foreach ($websiteIds as $websiteId) {
$websiteStores = Mage::app()->getWebsite($websiteId)->getStoreIds();
$storeIds = array_merge($storeIds, $websiteStores);
}
}
$this->setStoreIds($storeIds);
}
return $this->getData('store_ids');
}
getThumbnailUrl (   $width = 75,
  $height = 75 
)

Return re-sized thumbnail image URL

Deprecated:
since 1.1.5
Parameters
int$width
int$height
Returns
string

Definition at line 1818 of file Product.php.

References _getImageHelper().

{
return (string)$this->_getImageHelper()->init($this, 'thumbnail')->resize($width, $height);
}
getTierPrice (   $qty = null)

Get product tier price by qty

Parameters
double$qty
Returns
double

Definition at line 652 of file Product.php.

References getPriceModel().

{
return $this->getPriceModel()->getTierPrice($qty, $this);
}
getTierPriceCount ( )

Count how many tier prices we have for the product

Returns
int

Definition at line 662 of file Product.php.

References getPriceModel().

{
return $this->getPriceModel()->getTierPriceCount($this);
}
getTypeId ( )

Get product type identifier

Returns
string

Definition at line 233 of file Product.php.

References Varien_Object\_getData().

{
return $this->_getData('type_id');
}
getTypeInstance (   $singleton = false)

Retrieve type instance

Type instance implement type depended logic

Parameters
bool$singleton
Returns
Mage_Catalog_Model_Product_Type_Abstract

Definition at line 259 of file Product.php.

References $_typeInstance, $_typeInstanceSingleton, and Mage\getSingleton().

{
if ($singleton === true) {
if (is_null($this->_typeInstanceSingleton)) {
$this->_typeInstanceSingleton = Mage::getSingleton('catalog/product_type')
->factory($this, true);
}
}
if ($this->_typeInstance === null) {
$this->_typeInstance = Mage::getSingleton('catalog/product_type')
->factory($this);
}
}
getUpSellLinkCollection ( )

Retrieve collection up sell link

Returns
Mage_Catalog_Model_Resource_Product_Link_Collection

Definition at line 891 of file Product.php.

References getLinkInstance().

{
$collection = $this->getLinkInstance()->useUpSellLinks()
->getLinkCollection();
$collection->setProduct($this);
$collection->addLinkTypeIdFilter();
$collection->addProductIdFilter();
$collection->joinAttributes();
return $collection;
}
getUpSellProductCollection ( )

Retrieve collection up sell product

Returns
Mage_Catalog_Model_Resource_Product_Link_Product_Collection

Definition at line 877 of file Product.php.

References getLinkInstance().

{
$collection = $this->getLinkInstance()->useUpSellLinks()
->getProductCollection()
->setIsStrongMode();
$collection->setProduct($this);
return $collection;
}
getUpSellProductIds ( )

Retrieve up sell products identifiers

Returns
array

Definition at line 860 of file Product.php.

References $ids, array, Varien_Object\getData(), and getUpSellProducts().

{
if (!$this->hasUpSellProductIds()) {
$ids = array();
foreach ($this->getUpSellProducts() as $product) {
$ids[] = $product->getId();
}
$this->setUpSellProductIds($ids);
}
return $this->getData('up_sell_product_ids');
}
getUpSellProducts ( )

Retrieve array of up sell products

Returns
array

Definition at line 843 of file Product.php.

References array, Varien_Object\getData(), and getUpSellProductCollection().

{
if (!$this->hasUpSellProducts()) {
$products = array();
foreach ($this->getUpSellProductCollection() as $product) {
$products[] = $product;
}
$this->setUpSellProducts($products);
}
return $this->getData('up_sell_products');
}
getUrlInStore (   $params = array())

Retrieve URL in current store

Parameters
array$paramsthe route params
Returns
string

Definition at line 1424 of file Product.php.

References getUrlModel().

{
return $this->getUrlModel()->getUrlInStore($this, $params);
}
getUrlModel ( )

Get product url model

Returns
Mage_Catalog_Model_Product_Url

Definition at line 165 of file Product.php.

References $_urlModel, and Mage\getSingleton().

{
if ($this->_urlModel === null) {
$this->_urlModel = Mage::getSingleton('catalog/product_url');
}
}
getUrlPath (   $category = null)

Retrieve Product Url Path (include category)

Parameters
Mage_Catalog_Model_Category$category
Returns
string

Definition at line 1446 of file Product.php.

References $category, and getUrlModel().

{
return $this->getUrlModel()->getUrlPath($this, $category);
}
getVisibleInCatalogStatuses ( )

Returns visible status IDs in catalog

Returns
array

Definition at line 1217 of file Product.php.

References Mage\getSingleton().

{
return Mage::getSingleton('catalog/product_status')->getVisibleStatusIds();
}
getVisibleInSiteVisibilities ( )

Retrieve visible in site visibilities

Returns
array

Definition at line 1247 of file Product.php.

References Mage\getSingleton().

{
return Mage::getSingleton('catalog/product_visibility')->getVisibleInSiteIds();
}
getVisibleStatuses ( )

Retrieve visible statuses

Returns
array

Definition at line 1227 of file Product.php.

References Mage\getSingleton().

{
return Mage::getSingleton('catalog/product_status')->getVisibleStatusIds();
}
getWebsiteIds ( )

Retrieve product websites identifiers

Returns
array

Definition at line 406 of file Product.php.

References $ids, _getResource(), and Varien_Object\getData().

{
if (!$this->hasWebsiteIds()) {
$ids = $this->_getResource()->getWebsiteIds($this);
$this->setWebsiteIds($ids);
}
return $this->getData('website_ids');
}
getWeight ( )

Retrieve weight throught type instance

Returns
unknown

Definition at line 1596 of file Product.php.

References getTypeInstance().

{
return $this->getTypeInstance(true)->getWeight($this);
}
hasCustomOptions ( )

Checks if there custom option for this product

Returns
bool

Definition at line 1736 of file Product.php.

{
if (count($this->_customOptions)) {
return true;
} else {
return false;
}
}
isAvailable ( )

Check whether the product type or stock allows to purchase the product

Returns
bool

Definition at line 1314 of file Product.php.

References getTypeInstance(), and Mage\helper().

{
return $this->getTypeInstance(true)->isSalable($this)
|| Mage::helper('catalog/product')->getSkipSaleableCheck();
}
isComposite ( )

Check is product composite

Returns
bool

Definition at line 1565 of file Product.php.

References getTypeInstance().

{
return $this->getTypeInstance(true)->isComposite($this);
}
isConfigurable ( )

Check is product configurable

Returns
bool

Definition at line 1197 of file Product.php.

References getTypeId(), and Mage_Catalog_Model_Product_Type\TYPE_CONFIGURABLE.

isDisabled ( )

Checks whether product has disabled status

Returns
bool

Definition at line 2056 of file Product.php.

References getStatus(), and Mage_Catalog_Model_Product_Status\STATUS_DISABLED.

isDuplicable ( )

Checks product can be duplicated

Returns
boolean

Definition at line 1267 of file Product.php.

References $_isDuplicable.

{
}
isGrouped ( )

Check is product grouped

Returns
bool

Definition at line 1187 of file Product.php.

References getTypeId(), and Mage_Catalog_Model_Product_Type\TYPE_GROUPED.

isInStock ( )

Whether product available in stock

Returns
bool

Definition at line 1374 of file Product.php.

References getStatus(), and Mage_Catalog_Model_Product_Status\STATUS_ENABLED.

isProductsHasSku ( array  $productIds)

Check for empty SKU on each product

Parameters
array$productIds
Returns
boolean|null

Definition at line 1912 of file Product.php.

References _getResource().

{
$products = $this->_getResource()->getProductsSku($productIds);
if (count($products)) {
foreach ($products as $product) {
if (empty($product['sku'])) {
return false;
}
}
return true;
}
return null;
}
isRecurring ( )

Whether the product is a recurring payment

Returns
bool

Definition at line 1354 of file Product.php.

{
return $this->getIsRecurring() == '1';
}
isReservedAttribute (   $attribute)

Check whether attribute reserved or not

Parameters
Mage_Catalog_Model_Entity_Attribute$attributeAttribute model object
Returns
boolean

Definition at line 1854 of file Product.php.

References $attribute, and getReservedAttributes().

{
return $attribute->getIsUserDefined()
&& in_array($attribute->getAttributeCode(), $this->getReservedAttributes());
}
isSalable ( )

Check is product available for sale

Returns
bool

Definition at line 1290 of file Product.php.

References array, Mage\dispatchEvent(), and isAvailable().

{
Mage::dispatchEvent('catalog_product_is_salable_before', array(
'product' => $this
));
$salable = $this->isAvailable();
$object = new Varien_Object(array(
'product' => $this,
'is_salable' => $salable
));
Mage::dispatchEvent('catalog_product_is_salable_after', array(
'product' => $this,
'salable' => $object
));
return $object->getIsSalable();
}
isSaleable ( )

Alias for isSalable()

Returns
bool

Definition at line 1364 of file Product.php.

References isSalable().

{
return $this->isSalable();
}
isSuper ( )

Whether product configurable or grouped

Returns
bool

Definition at line 1207 of file Product.php.

References isConfigurable(), and isGrouped().

{
return $this->isConfigurable() || $this->isGrouped();
}
isSuperConfig ( )

Alias for isConfigurable()

Returns
bool

Definition at line 1178 of file Product.php.

References isConfigurable().

{
return $this->isConfigurable();
}
isSuperGroup ( )

Is product grouped

Returns
bool

Definition at line 1168 of file Product.php.

References getTypeId(), and Mage_Catalog_Model_Product_Type\TYPE_GROUPED.

isVirtual ( )

Check is a virtual product Data helper wrapper

Returns
bool

Definition at line 1344 of file Product.php.

References getIsVirtual().

{
return $this->getIsVirtual();
}
isVisibleInCatalog ( )

Check Product visilbe in catalog

Returns
bool

Definition at line 1237 of file Product.php.

References getStatus(), and getVisibleInCatalogStatuses().

{
return in_array($this->getStatus(), $this->getVisibleInCatalogStatuses());
}
isVisibleInSiteVisibility ( )

Check Product visible in site

Returns
bool

Definition at line 1257 of file Product.php.

References getVisibleInSiteVisibilities().

{
return in_array($this->getVisibility(), $this->getVisibleInSiteVisibilities());
}
loadParentProductIds ( )
Deprecated:
after 1.4.2.0
Returns
Mage_Catalog_Model_Product

Definition at line 1513 of file Product.php.

References array.

{
return $this->setParentProductIds(array());
}
prepareCustomOptions ( )

Prepare product custom options. To be sure that all product custom options does not has ID and has product instance

Returns
Mage_Catalog_Model_Product

Definition at line 1974 of file Product.php.

References addCustomOption(), and getCustomOptions().

{
foreach ($this->getCustomOptions() as $option) {
if (!is_object($option->getProduct()) || $option->getId()) {
$this->addCustomOption($option->getCode(), $option->getValue());
}
}
return $this;
}
processBuyRequest ( Varien_Object  $buyRequest)

Parse buyRequest into options values used by product

Parameters
Varien_Object$buyRequest
Returns
Varien_Object

Definition at line 1932 of file Product.php.

References $options, array, and getTypeInstance().

{
/* add product custom options data */
$customOptions = $buyRequest->getOptions();
if (is_array($customOptions)) {
$options->setOptions(array_diff($buyRequest->getOptions(), array('')));
}
/* add product type selected options data */
$type = $this->getTypeInstance(true);
$typeSpecificOptions = $type->processBuyRequest($this, $buyRequest);
$options->addData($typeSpecificOptions);
/* check correctness of product's options */
$options->setErrors($type->checkProductConfiguration($this, $buyRequest));
return $options;
}
reset ( )

Reset all model data

Returns
Mage_Catalog_Model_Product

Definition at line 1881 of file Product.php.

References _clearData(), and Mage_Catalog_Model_Abstract\unlockAttributes().

{
$this->unlockAttributes();
$this->_clearData();
return $this;
}
setCategoryIds (   $ids)

Set assigned category IDs array to product

Parameters
array | string$ids
Returns
Mage_Catalog_Model_Product

Definition at line 351 of file Product.php.

References $ids, __(), Mage\helper(), Mage_Catalog_Model_Abstract\setData(), and Mage\throwException().

{
if (is_string($ids)) {
$ids = explode(',', $ids);
} elseif (!is_array($ids)) {
Mage::throwException(Mage::helper('catalog')->__('Invalid category IDs.'));
}
foreach ($ids as $i => $v) {
if (empty($v)) {
unset($ids[$i]);
}
}
$this->setData('category_ids', $ids);
return $this;
}
setCustomOptions ( array  $options)

Sets custom options for the product

Parameters
array$optionsArray of options
Returns
void

Definition at line 1702 of file Product.php.

References $options.

{
$this->_customOptions = $options;
}
setFinalPrice (   $price)

Sets final price of product

This func is equal to magic 'setFinalPrice()', but added as a separate func, because in cart with bundle products it's called very often in Item->getProduct(). So removing chain of magic with more cpu consuming algorithms gives nice optimization boost.

Parameters
float$pricePrice amount
Returns
Mage_Catalog_Model_Product

Definition at line 698 of file Product.php.

{
$this->_data['final_price'] = $price;
return $this;
}
setIsDuplicable (   $value)

Set is duplicable flag

Parameters
boolean$value
Returns
Mage_Catalog_Model_Product

Definition at line 1278 of file Product.php.

{
$this->_isDuplicable = (boolean) $value;
return $this;
}
setOrigData (   $key = null,
  $data = null 
)

Set original loaded data if needed

Parameters
string$key
mixed$data
Returns
Varien_Object

Definition at line 1867 of file Product.php.

References $data, Mage\app(), and Mage_Catalog_Model_Abstract\getStore().

{
if (Mage::app()->getStore()->isAdmin()) {
return parent::setOrigData($key, $data);
}
return $this;
}
setPriceCalculation (   $calculate = true)

Set Price calculation flag

Parameters
bool$calculate
Returns
void

Definition at line 223 of file Product.php.

{
$this->_calculatePrice = $calculate;
}
setTypeInstance (   $instance,
  $singleton = false 
)

Set type instance for external

Parameters
Mage_Catalog_Model_Product_Type_Abstract$instanceProduct type instance
bool$singletonWhether instance is singleton
Returns
Mage_Catalog_Model_Product

Definition at line 283 of file Product.php.

{
if ($singleton === true) {
$this->_typeInstanceSingleton = $instance;
} else {
$this->_typeInstance = $instance;
}
return $this;
}
toArray ( array  $arrAttributes = array())

Renders the object to array

Parameters
array$arrAttributesAttribute array
Returns
array

Definition at line 1478 of file Product.php.

References $data.

{
$data = parent::toArray($arrAttributes);
if ($stock = $this->getStockItem()) {
$data['stock_item'] = $stock->toArray();
}
unset($data['stock_item']['product']);
return $data;
}
validate ( )

Validate Product Data

Todo:
implement full validation process with errors returning which are ignoring now
Returns
Mage_Catalog_Model_Product

Definition at line 180 of file Product.php.

References _getResource(), array, and Mage\dispatchEvent().

{
// $this->getAttributes();
// Mage::dispatchEvent($this->_eventPrefix.'_validate_before', array($this->_eventObject=>$this));
// $result = $this->_getResource()->validate($this);
// Mage::dispatchEvent($this->_eventPrefix.'_validate_after', array($this->_eventObject=>$this));
// return $result;
Mage::dispatchEvent($this->_eventPrefix.'_validate_before', array($this->_eventObject=>$this));
$this->_getResource()->validate($this);
Mage::dispatchEvent($this->_eventPrefix.'_validate_after', array($this->_eventObject=>$this));
return $this;
}

Member Data Documentation

$_cacheTag = 'catalog_product'
protected

Definition at line 46 of file Product.php.

$_calculatePrice = true
protected

Definition at line 110 of file Product.php.

$_canAffectOptions = false
protected

Definition at line 49 of file Product.php.

$_customOptions = array()
protected

Definition at line 75 of file Product.php.

$_errors = array()
protected

Definition at line 87 of file Product.php.

$_eventObject = 'product'
protected

Definition at line 48 of file Product.php.

$_eventPrefix = 'catalog_product'
protected

Definition at line 47 of file Product.php.

$_isDuplicable = true
protected

Definition at line 103 of file Product.php.

$_linkInstance
protected

Definition at line 68 of file Product.php.

$_optionInstance
protected

Definition at line 89 of file Product.php.

$_options = array()
protected

Definition at line 91 of file Product.php.

$_reservedAttributes
protected

Product reserved attribute codes

Definition at line 96 of file Product.php.

$_typeInstance = null
protected

Definition at line 56 of file Product.php.

$_typeInstanceSingleton = null
protected

Product type instance as singleton

Definition at line 61 of file Product.php.

$_url
staticprotected

Definition at line 84 of file Product.php.

$_urlModel = null
protected

Definition at line 82 of file Product.php.

$_urlRewrite
staticprotected

Definition at line 85 of file Product.php.

const CACHE_TAG = 'catalog_product'

Definition at line 45 of file Product.php.

const ENTITY = 'catalog_product'

Entity code. Can be used as part of method name for entity processing

Definition at line 43 of file Product.php.


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