Mage_Sitemap_Model_Mysql4_Catalog_Product Class Reference

Inheritance diagram for Mage_Sitemap_Model_Mysql4_Catalog_Product:

Mage_Core_Model_Mysql4_Abstract Mage_Core_Model_Resource_Abstract

List of all members.

Public Member Functions

 getCollection ($storeId)

Protected Member Functions

 _construct ()
 _addFilter ($storeId, $attributeCode, $value, $type= '=')
 _prepareProduct (array $productRow)

Protected Attributes

 $_select
 $_attributesCache = array()


Detailed Description

Definition at line 35 of file Product.php.


Member Function Documentation

_addFilter ( storeId,
attributeCode,
value,
type = '=' 
) [protected]

Add attribute to filter

Parameters:
int $storeId
string $attributeCode
mixed $value
string $type
Returns:
Zend_Db_Select

Definition at line 69 of file Product.php.

00070     {
00071         if (!isset($this->_attributesCache[$attributeCode])) {
00072             $attribute = Mage::getSingleton('catalog/product')->getResource()->getAttribute($attributeCode);
00073 
00074             $this->_attributesCache[$attributeCode] = array(
00075                 'entity_type_id'    => $attribute->getEntityTypeId(),
00076                 'attribute_id'      => $attribute->getId(),
00077                 'table'             => $attribute->getBackend()->getTable(),
00078                 'is_global'         => $attribute->getIsGlobal() == Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
00079                 'backend_type'      => $attribute->getBackendType()
00080             );
00081         }
00082 
00083         $attribute = $this->_attributesCache[$attributeCode];
00084 
00085         if (!$this->_select instanceof Zend_Db_Select) {
00086             return false;
00087         }
00088 
00089         switch ($type) {
00090             case '=':
00091                 $conditionRule = '=?';
00092                 break;
00093             case 'in':
00094                 $conditionRule = ' IN(?)';
00095                 break;
00096             default:
00097                 return false;
00098                 break;
00099         }
00100 
00101         if ($attribute['backend_type'] == 'static') {
00102             $this->_select->where('e.' . $attributeCode . $conditionRule, $value);
00103         }
00104         else {
00105             if ($attribute['is_global']) {
00106 
00107             }
00108             else {
00109                 $this->_select->join(
00110                     array('t1_'.$attributeCode => $attribute['table']),
00111                     'e.entity_id=t1_'.$attributeCode.'.entity_id AND t1_'.$attributeCode.'.store_id=0',
00112                     array()
00113                 )
00114                 ->joinLeft(
00115                     array('t2_'.$attributeCode => $attribute['table']),
00116                     $this->_getWriteAdapter()->quoteInto('t1_'.$attributeCode.'.entity_id = t2_'.$attributeCode.'.entity_id AND t1_'.$attributeCode.'.attribute_id = t2_'.$attributeCode.'.attribute_id AND t2_'.$attributeCode.'.store_id=?', $storeId),
00117                     array()
00118                 )
00119                 ->where('t1_'.$attributeCode.'.attribute_id=?', $attribute['attribute_id'])
00120                 ->where('IFNULL(t2_'.$attributeCode.'.value, t1_'.$attributeCode.'.value)'.$conditionRule, $value);
00121             }
00122         }
00123 
00124         return $this->_select;
00125     }

_construct (  )  [protected]

Init resource model (catalog/category)

Reimplemented from Mage_Core_Model_Resource_Abstract.

Definition at line 54 of file Product.php.

00055     {
00056         $this->_init('catalog/product', 'entity_id');
00057     }

_prepareProduct ( array productRow  )  [protected]

Prepare product

Parameters:
array $productRow
Returns:
Varien_Object

Definition at line 183 of file Product.php.

00184     {
00185         $product = new Varien_Object();
00186         $product->setId($productRow[$this->getIdFieldName()]);
00187         $productUrl = !empty($productRow['url']) ? $productRow['url'] : 'catalog/product/view/id/' . $product->getId();
00188         $product->setUrl($productUrl);
00189         return $product;
00190     }

getCollection ( storeId  ) 

Get category collection array

Returns:
array

Definition at line 133 of file Product.php.

00134     {
00135         $products = array();
00136 
00137         $store = Mage::app()->getStore($storeId);
00138         /* @var $store Mage_Core_Model_Store */
00139 
00140         if (!$store) {
00141             return false;
00142         }
00143 
00144         $urCondions = array(
00145             'e.entity_id=ur.product_id',
00146             'ur.category_id IS NULL',
00147             $this->_getWriteAdapter()->quoteInto('ur.store_id=?', $store->getId()),
00148             $this->_getWriteAdapter()->quoteInto('ur.is_system=?', 1),
00149         );
00150         $this->_select = $this->_getWriteAdapter()->select()
00151             ->from(array('e' => $this->getMainTable()), array($this->getIdFieldName()))
00152             ->join(
00153                 array('w' => $this->getTable('catalog/product_website')),
00154                 'e.entity_id=w.product_id',
00155                 array()
00156             )
00157             ->where('w.website_id=?', $store->getWebsiteId())
00158             ->joinLeft(
00159                 array('ur' => $this->getTable('core/url_rewrite')),
00160                 join(' AND ', $urCondions),
00161                 array('url' => 'request_path')
00162             )
00163             ;
00164 
00165         $this->_addFilter($storeId, 'visibility', Mage::getSingleton('catalog/product_visibility')->getVisibleInSearchIds(), 'in');
00166         $this->_addFilter($storeId, 'status', Mage::getSingleton('catalog/product_status')->getVisibleStatusIds(), 'in');
00167 
00168         $query = $this->_getWriteAdapter()->query($this->_select);
00169         while ($row = $query->fetch()) {
00170             $product = $this->_prepareProduct($row);
00171             $products[$product->getId()] = $product;
00172         }
00173 
00174         return $products;
00175     }


Member Data Documentation

$_attributesCache = array() [protected]

Definition at line 49 of file Product.php.

$_select [protected]

Definition at line 42 of file Product.php.


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

Generated on Sat Jul 4 17:24:52 2009 for Magento by  doxygen 1.5.8