Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Option_Collection Class Reference

Inheritance diagram for Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Option_Collection:

Mage_Core_Model_Mysql4_Collection_Abstract Varien_Data_Collection_Db Varien_Data_Collection

List of all members.

Public Member Functions

 getOptions ($store_id)
 addTitleToResult ($store_id)
 addPriceToResult ($store_id)
 addValuesToResult ($storeId=null)
 addProductToFilter ($product)
 reset ()

Protected Member Functions

 _construct ()


Detailed Description

Definition at line 35 of file Collection.php.


Member Function Documentation

_construct (  )  [protected]

Initialization here

Reimplemented from Mage_Core_Model_Mysql4_Collection_Abstract.

Definition at line 38 of file Collection.php.

00039     {
00040         $this->_init('catalog/product_option');
00041     }

addPriceToResult ( store_id  ) 

Definition at line 81 of file Collection.php.

00082     {
00083         $this->getSelect()
00084             ->joinLeft(array('default_option_price'=>$this->getTable('catalog/product_option_price')),
00085                 '`default_option_price`.option_id=`main_table`.option_id AND '.$this->getConnection()->quoteInto('`default_option_price`.store_id=?',0),
00086                 array('default_price'=>'price','default_price_type'=>'price_type'))
00087             ->joinLeft(array('store_option_price'=>$this->getTable('catalog/product_option_price')),
00088                 '`store_option_price`.option_id=`main_table`.option_id AND '.$this->getConnection()->quoteInto('`store_option_price`.store_id=?', $store_id),
00089                 array('store_price'=>'price','store_price_type'=>'price_type',
00090                 'price'=>new Zend_Db_Expr('IFNULL(`store_option_price`.price,`default_option_price`.price)'),
00091                 'price_type'=>new Zend_Db_Expr('IFNULL(`store_option_price`.price_type,`default_option_price`.price_type)')));
00092         return $this;
00093     }

addProductToFilter ( product  ) 

Definition at line 124 of file Collection.php.

00125     {
00126         if (empty($product)) {
00127             $this->addFieldToFilter('product_id', '');
00128         } elseif (is_array($product)) {
00129             $this->addFieldToFilter('product_id', array('in' => $product));
00130         } elseif ($product instanceof Mage_Catalog_Model_Product) {
00131             $this->addFieldToFilter('product_id', $product->getId());
00132         } else {
00133             $this->addFieldToFilter('product_id', $product);
00134         }
00135 
00136         return $this;
00137     }

addTitleToResult ( store_id  ) 

Definition at line 66 of file Collection.php.

00067     {
00068         $this->getSelect()
00069             ->join(array('default_option_title'=>$this->getTable('catalog/product_option_title')),
00070                 '`default_option_title`.option_id=`main_table`.option_id',
00071                 array('default_title'=>'title'))
00072             ->joinLeft(array('store_option_title'=>$this->getTable('catalog/product_option_title')),
00073                 '`store_option_title`.option_id=`main_table`.option_id AND '.$this->getConnection()->quoteInto('`store_option_title`.store_id=?', $store_id),
00074                 array('store_title'=>'title',
00075                 'title'=>new Zend_Db_Expr('IFNULL(`store_option_title`.title,`default_option_title`.title)')))
00076             ->where('`default_option_title`.store_id=?', 0);
00077 
00078         return $this;
00079     }

addValuesToResult ( storeId = null  ) 

Definition at line 95 of file Collection.php.

00096     {
00097         if (null === $storeId) {
00098             $storeId = Mage::app()->getStore()->getId();
00099         }
00100         $optionIds = array();
00101         foreach ($this as $option) {
00102             $optionIds[] = $option->getId();
00103         }
00104         if (!empty($optionIds)) {
00105             $values = Mage::getModel('catalog/product_option_value')
00106                 ->getCollection()
00107                 ->addTitleToResult($storeId)
00108                 ->addPriceToResult($storeId)
00109                 ->addOptionToFilter($optionIds)
00110                 ->setOrder('sort_order', 'asc')
00111                 ->setOrder('title', 'asc');
00112 
00113             foreach ($values as $value) {
00114                 if($this->getItemById($value->getOptionId())) {
00115                     $this->getItemById($value->getOptionId())->addValue($value);
00116                     $value->setOption($this->getItemById($value->getOptionId()));
00117                 }
00118             }
00119         }
00120 
00121         return $this;
00122     }

getOptions ( store_id  ) 

Definition at line 43 of file Collection.php.

00044     {
00045         $this->getSelect()
00046             ->joinLeft(array('default_option_price'=>$this->getTable('catalog/product_option_price')),
00047                 '`default_option_price`.option_id=`main_table`.option_id AND '.$this->getConnection()->quoteInto('`default_option_price`.store_id=?',0),
00048                 array('default_price'=>'price','default_price_type'=>'price_type'))
00049             ->joinLeft(array('store_option_price'=>$this->getTable('catalog/product_option_price')),
00050                 '`store_option_price`.option_id=`main_table`.option_id AND '.$this->getConnection()->quoteInto('`store_option_price`.store_id=?', $store_id),
00051                 array('store_price'=>'price','store_price_type'=>'price_type',
00052                 'price'=>new Zend_Db_Expr('IFNULL(`store_option_price`.price,`default_option_price`.price)'),
00053                 'price_type'=>new Zend_Db_Expr('IFNULL(`store_option_price`.price_type,`default_option_price`.price_type)')))
00054             ->join(array('default_option_title'=>$this->getTable('catalog/product_option_title')),
00055                 '`default_option_title`.option_id=`main_table`.option_id',
00056                 array('default_title'=>'title'))
00057             ->joinLeft(array('store_option_title'=>$this->getTable('catalog/product_option_title')),
00058                 '`store_option_title`.option_id=`main_table`.option_id AND '.$this->getConnection()->quoteInto('`store_option_title`.store_id=?', $store_id),
00059                 array('store_title'=>'title',
00060                 'title'=>new Zend_Db_Expr('IFNULL(`store_option_title`.title,`default_option_title`.title)')))
00061             ->where('`default_option_title`.store_id=?', 0);
00062 
00063         return $this;
00064     }

reset (  ) 

Call of protected method reset

Returns:
Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Option_Collection

Definition at line 144 of file Collection.php.

00144                             {
00145         return $this->_reset();
00146     }


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

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