Mage_Catalog_Model_Api_Resource Class Reference

Inheritance diagram for Mage_Catalog_Model_Api_Resource:

Mage_Api_Model_Resource_Abstract Mage_Catalog_Model_Category_Api Mage_Catalog_Model_Category_Attribute_Api Mage_Catalog_Model_Product_Api Mage_Catalog_Model_Product_Attribute_Api Mage_Catalog_Model_Product_Attribute_Media_Api Mage_Catalog_Model_Product_Attribute_Tierprice_Api Mage_Catalog_Model_Product_Link_Api Mage_CatalogInventory_Model_Stock_Item_Api

List of all members.

Public Member Functions

 currentStore ($store=null)

Protected Member Functions

 _isAllowedAttribute ($attribute, $attributes=null)
 _getStoreId ($store=null)
 _getProduct ($productId, $store=null)

Protected Attributes

 $_ignoredAttributeCodes = array('entity_id', 'attribute_set_id', 'entity_type_id')
 $_ignoredAttributeTypes = array()
 $_storeIdSessionField = 'store_id'


Detailed Description

Definition at line 34 of file Resource.php.


Member Function Documentation

_getProduct ( productId,
store = null 
) [protected]

Return loaded product instance

Parameters:
int|string $productId (SKU or ID)
int|string $store
Returns:
Mage_Catalog_Model_Product

Definition at line 105 of file Resource.php.

00106     {
00107         $product = Mage::getModel('catalog/product');
00108 
00109         /* @var $product Mage_Catalog_Model_Product */
00110 
00111         if (is_string($productId)) {
00112             $idBySku = $product->getIdBySku($productId);
00113             if ($idBySku) {
00114                 $productId = $idBySku;
00115             }
00116         }
00117         if ($store !== null) {
00118             $product->setStoreId($this->_getStoreId($store));
00119         }
00120         $product->load($productId);
00121         return $product;
00122     }

_getStoreId ( store = null  )  [protected]

Retrives store id from store code, if no store id specified, it use seted session or admin store

Parameters:
string|int $store
Returns:
int

Definition at line 82 of file Resource.php.

00083     {
00084         if (is_null($store)) {
00085             $store = ($this->_getSession()->hasData($this->_storeIdSessionField)
00086                         ? $this->_getSession()->getData($this->_storeIdSessionField) : 0);
00087         }
00088 
00089         try {
00090             $storeId = Mage::app()->getStore($store)->getId();
00091         } catch (Mage_Core_Model_Store_Exception $e) {
00092             $this->_fault('store_not_exists');
00093         }
00094 
00095         return $storeId;
00096     }

_isAllowedAttribute ( attribute,
attributes = null 
) [protected]

Check is attribute allowed

Parameters:
Mage_Eav_Model_Entity_Attribute_Abstract $attribute
array $attributes
Returns:
boolean

Definition at line 63 of file Resource.php.

00064     {
00065         if (is_array($attributes)
00066             && !( in_array($attribute->getAttributeCode(), $attributes)
00067                   || in_array($attribute->getAttributeId(), $attributes))) {
00068             return false;
00069         }
00070 
00071         return !in_array($attribute->getFrontendInput(), $this->_ignoredAttributeTypes)
00072                && !in_array($attribute->getAttributeCode(), $this->_ignoredAttributeCodes);
00073     }

currentStore ( store = null  ) 

Set current store for catalog.

Parameters:
string|int $store
Returns:
int

Definition at line 130 of file Resource.php.

00131     {
00132         if (!is_null($store)) {
00133             try {
00134                 $storeId = Mage::app()->getStore($store)->getId();
00135             } catch (Mage_Core_Model_Store_Exception $e) {
00136                 $this->_fault('store_not_exists');
00137             }
00138 
00139             $this->_getSession()->setData($this->_storeIdSessionField, $storeId);
00140         }
00141 
00142         return $this->_getStoreId();
00143     }


Member Data Documentation

$_ignoredAttributeCodes = array('entity_id', 'attribute_set_id', 'entity_type_id') [protected]

Definition at line 41 of file Resource.php.

$_ignoredAttributeTypes = array() [protected]

Definition at line 48 of file Resource.php.

$_storeIdSessionField = 'store_id' [protected]

Definition at line 54 of file Resource.php.


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

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