Mage_Bundle_Model_Mysql4_Option Class Reference

Inheritance diagram for Mage_Bundle_Model_Mysql4_Option:

Mage_Core_Model_Mysql4_Abstract Mage_Core_Model_Resource_Abstract

List of all members.

Public Member Functions

 getSearchableData ($productId, $storeId)

Protected Member Functions

 _construct ()
 _afterSave (Mage_Core_Model_Abstract $object)
 _afterDelete (Mage_Core_Model_Abstract $object)


Detailed Description

Definition at line 34 of file Option.php.


Member Function Documentation

_afterDelete ( Mage_Core_Model_Abstract object  )  [protected]

After delete process

Parameters:
Mage_Core_Model_Abstract $object
Returns:
Mage_Bundle_Model_Mysql4_Option

Reimplemented from Mage_Core_Model_Mysql4_Abstract.

Definition at line 87 of file Option.php.

00088     {
00089         parent::_afterDelete($object);
00090 
00091         $condition = $this->_getWriteAdapter()->quoteInto('option_id = ?', $object->getId());
00092         $this->_getWriteAdapter()->delete($this->getTable('option_value'), $condition);
00093 
00094         return $this;
00095     }

_afterSave ( Mage_Core_Model_Abstract object  )  [protected]

After save process

Parameters:
Mage_Core_Model_Abstract $object
Returns:
Mage_Bundle_Model_Mysql4_Option

also saving default value if this store view scope

Reimplemented from Mage_Core_Model_Mysql4_Abstract.

Definition at line 51 of file Option.php.

00052     {
00053         parent::_afterSave($object);
00054 
00055         $condition = $this->_getWriteAdapter()->quoteInto('option_id = ?', $object->getId());
00056         $condition .= ' and (' . $this->_getWriteAdapter()->quoteInto('store_id = ?', $object->getStoreId());
00057         $condition .= ' or store_id = 0)';
00058 
00059         $this->_getWriteAdapter()->delete($this->getTable('option_value'), $condition);
00060 
00061         $data = new Varien_Object();
00062         $data->setOptionId($object->getId())
00063             ->setStoreId($object->getStoreId())
00064             ->setTitle($object->getTitle());
00065 
00066         $this->_getWriteAdapter()->insert($this->getTable('option_value'), $data->getData());
00067 
00068         /**
00069          * also saving default value if this store view scope
00070          */
00071 
00072         if ($object->getStoreId()) {
00073             $data->setStoreId('0');
00074             $data->setTitle($object->getDefaultTitle());
00075             $this->_getWriteAdapter()->insert($this->getTable('option_value'), $data->getData());
00076         }
00077 
00078         return $this;
00079     }

_construct (  )  [protected]

Initialize connection and define resource

Reimplemented from Mage_Core_Model_Resource_Abstract.

Definition at line 40 of file Option.php.

00041     {
00042         $this->_init('bundle/option', 'option_id');
00043     }

getSearchableData ( productId,
storeId 
)

Retrieve options searchable data

Parameters:
int $productId
int $storeId
Returns:
array

Definition at line 104 of file Option.php.

00105     {
00106         $select = $this->_getReadAdapter()->select()
00107             ->from(array('option' => $this->getMainTable()), null)
00108             ->join(
00109                 array('option_title_default' => $this->getTable('bundle/option_value')),
00110                 'option_title_default.option_id=option.option_id AND option_title_default.store_id=0',
00111                 array())
00112             ->joinLeft(
00113                 array('option_title_store' => $this->getTable('bundle/option_value')),
00114                 'option_title_store.option_id=option.option_id AND option_title_store.store_id=' . intval($storeId),
00115                 array('title' => 'IFNULL(option_title_store.title, option_title_default.title)'))
00116             ->where('option.parent_id=?', $productId);
00117         if (!$searchData = $this->_getReadAdapter()->fetchCol($select)) {
00118             $searchData = array();
00119         }
00120         return $searchData;
00121     }


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

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