Mage_Catalog_Model_Product_Visibility Class Reference

Inheritance diagram for Mage_Catalog_Model_Product_Visibility:

Varien_Object

List of all members.

Public Member Functions

 __construct ()
 addVisibleInCatalogFilterToCollection (Mage_Eav_Model_Entity_Collection_Abstract $collection)
 addVisibleInSearchFilterToCollection (Mage_Eav_Model_Entity_Collection_Abstract $collection)
 addVisibleInSiteFilterToCollection (Mage_Eav_Model_Entity_Collection_Abstract $collection)
 getVisibleInCatalogIds ()
 getVisibleInSearchIds ()
 getVisibleInSiteIds ()
 getFlatColums ()
 getFlatIndexes ()
 getFlatUpdateSelect ($store)
 setAttribute ($attribute)
 getAttribute ()
 addValueSortToCollection ($collection, $dir= 'asc')

Static Public Member Functions

static getOptionArray ()
static getAllOption ()
static getAllOptions ()
static getOptionText ($optionId)

Public Attributes

const VISIBILITY_NOT_VISIBLE = 1
const VISIBILITY_IN_CATALOG = 2
const VISIBILITY_IN_SEARCH = 3
const VISIBILITY_BOTH = 4

Protected Attributes

 $_attribute


Detailed Description

Definition at line 35 of file Visibility.php.


Constructor & Destructor Documentation

__construct (  ) 

Initialize object

Reimplemented from Varien_Object.

Definition at line 53 of file Visibility.php.

00054     {
00055         parent::__construct();
00056         $this->setIdFieldName('visibility_id');
00057     }


Member Function Documentation

addValueSortToCollection ( collection,
dir = 'asc' 
)

Add Value Sort To Collection Select

Parameters:
Mage_Eav_Model_Entity_Collection_Abstract $collection
string $dir direction
Returns:
Mage_Eav_Model_Entity_Attribute_Source_Abstract

Definition at line 249 of file Visibility.php.

00250     {
00251         if ($this->getAttribute()->isScopeGlobal()) {
00252             $tableName = $this->getAttribute()->getAttributeCode() . '_t';
00253             $collection->getSelect()
00254                 ->joinLeft(
00255                     array($tableName => $this->getAttribute()->getBackend()->getTable()),
00256                     "`e`.`entity_id`=`{$tableName}`.`entity_id`"
00257                         . " AND `{$tableName}`.`attribute_id`='{$this->getAttribute()->getId()}'"
00258                         . " AND `{$tableName}`.`store_id`='0'",
00259                     array());
00260             $valueExpr = $tableName . '.value';
00261         }
00262         else {
00263             $valueTable1    = $this->getAttribute()->getAttributeCode() . '_t1';
00264             $valueTable2    = $this->getAttribute()->getAttributeCode() . '_t2';
00265             $collection->getSelect()
00266                 ->joinLeft(
00267                     array($valueTable1 => $this->getAttribute()->getBackend()->getTable()),
00268                     "`e`.`entity_id`=`{$valueTable1}`.`entity_id`"
00269                         . " AND `{$valueTable1}`.`attribute_id`='{$this->getAttribute()->getId()}'"
00270                         . " AND `{$valueTable1}`.`store_id`='0'",
00271                     array())
00272                 ->joinLeft(
00273                     array($valueTable2 => $this->getAttribute()->getBackend()->getTable()),
00274                     "`e`.`entity_id`=`{$valueTable2}`.`entity_id`"
00275                         . " AND `{$valueTable2}`.`attribute_id`='{$this->getAttribute()->getId()}'"
00276                         . " AND `{$valueTable2}`.`store_id`='{$collection->getStoreId()}'",
00277                     array()
00278                 );
00279             $valueExpr = new Zend_Db_Expr("IFNULL(`{$valueTable2}`.`value`, `{$valueTable1}`.`value`)");
00280         }
00281 
00282         $collection->getSelect()->order($valueExpr . ' ' . $dir);
00283         return $this;
00284     }

addVisibleInCatalogFilterToCollection ( Mage_Eav_Model_Entity_Collection_Abstract collection  ) 

Add visible in catalog filter to collection

Deprecated:
Parameters:
Mage_Eav_Model_Entity_Collection_Abstract $collection
Returns:
Mage_Catalog_Model_Product_Visibility

Definition at line 66 of file Visibility.php.

00067     {
00068         $collection->setVisibility($this->getVisibleInCatalogIds());
00069 //        $collection->addAttributeToFilter('visibility', array('in'=>$this->getVisibleInCatalogIds()));
00070         return $this;
00071     }

addVisibleInSearchFilterToCollection ( Mage_Eav_Model_Entity_Collection_Abstract collection  ) 

Add visibility in searchfilter to collection

Deprecated:
Parameters:
Mage_Eav_Model_Entity_Collection_Abstract $collection
Returns:
Mage_Catalog_Model_Product_Visibility

Definition at line 80 of file Visibility.php.

00081     {
00082         $collection->setVisibility($this->getVisibleInSearchIds());
00083         //$collection->addAttributeToFilter('visibility', array('in'=>$this->getVisibleInSearchIds()));
00084         return $this;
00085     }

addVisibleInSiteFilterToCollection ( Mage_Eav_Model_Entity_Collection_Abstract collection  ) 

Add visibility in site filter to collection

Deprecated:
Parameters:
Mage_Eav_Model_Entity_Collection_Abstract $collection
Returns:
Mage_Catalog_Model_Product_Visibility

Definition at line 94 of file Visibility.php.

00095     {
00096         $collection->setVisibility($this->getVisibleInSiteIds());
00097         //$collection->addAttributeToFilter('visibility', array('in'=>$this->getVisibleInSiteIds()));
00098         return $this;
00099     }

static getAllOption (  )  [static]

Retrieve all options

Returns:
array

Definition at line 151 of file Visibility.php.

00152     {
00153         $options = self::getOptionArray();
00154         array_unshift($options, array('value'=>'', 'label'=>''));
00155         return $options;
00156     }

static getAllOptions (  )  [static]

Retireve all options

Returns:
array

Definition at line 163 of file Visibility.php.

00164     {
00165         $res = array();
00166         $res[] = array('value'=>'', 'label'=> Mage::helper('catalog')->__('-- Please Select --'));
00167         foreach (self::getOptionArray() as $index => $value) {
00168             $res[] = array(
00169                'value' => $index,
00170                'label' => $value
00171             );
00172         }
00173         return $res;
00174     }

getAttribute (  ) 

Get attribute instance

Returns:
Mage_Catalog_Model_Resource_Eav_Attribute

Definition at line 237 of file Visibility.php.

00238     {
00239         return $this->_attribute;
00240     }

getFlatColums (  ) 

Retrieve Column(s) for Flat

Returns:
array

Definition at line 193 of file Visibility.php.

00194     {
00195         return array();
00196     }

getFlatIndexes (  ) 

Retrieve Indexes for Flat

Returns:
array

Definition at line 203 of file Visibility.php.

00204     {
00205         return array();
00206     }

getFlatUpdateSelect ( store  ) 

Retrieve Select For Flat Attribute update

Parameters:
Mage_Catalog_Model_Resource_Eav_Attribute $attribute
int $store
Returns:
Varien_Db_Select|null

Definition at line 215 of file Visibility.php.

00216     {
00217         return null;
00218     }

static getOptionArray (  )  [static]

Retrieve option array

Returns:
array

Definition at line 136 of file Visibility.php.

00137     {
00138         return array(
00139             self::VISIBILITY_NOT_VISIBLE=> Mage::helper('catalog')->__('Nowhere'),
00140             self::VISIBILITY_IN_CATALOG => Mage::helper('catalog')->__('Catalog'),
00141             self::VISIBILITY_IN_SEARCH  => Mage::helper('catalog')->__('Search'),
00142             self::VISIBILITY_BOTH       => Mage::helper('catalog')->__('Catalog, Search')
00143         );
00144     }

static getOptionText ( optionId  )  [static]

Retrieve option text

Parameters:
int $optionId
Returns:
string

Definition at line 182 of file Visibility.php.

00183     {
00184         $options = self::getOptionArray();
00185         return isset($options[$optionId]) ? $options[$optionId] : null;
00186     }

getVisibleInCatalogIds (  ) 

Retrieve visible in catalog ids array

Returns:
array

Definition at line 106 of file Visibility.php.

00107     {
00108         return array(self::VISIBILITY_IN_CATALOG, self::VISIBILITY_BOTH);
00109     }

getVisibleInSearchIds (  ) 

Retrieve visible in search ids array

Returns:
array

Definition at line 116 of file Visibility.php.

00117     {
00118         return array(self::VISIBILITY_IN_SEARCH, self::VISIBILITY_BOTH);
00119     }

getVisibleInSiteIds (  ) 

Retrieve visible in site ids array

Returns:
array

Definition at line 126 of file Visibility.php.

00127     {
00128         return array(self::VISIBILITY_IN_SEARCH, self::VISIBILITY_IN_CATALOG, self::VISIBILITY_BOTH);
00129     }

setAttribute ( attribute  ) 

Set attribute instance

Parameters:
Mage_Catalog_Model_Resource_Eav_Attribute $attribute
Returns:
Mage_Eav_Model_Entity_Attribute_Frontend_Abstract

Definition at line 226 of file Visibility.php.

00227     {
00228         $this->_attribute = $attribute;
00229         return $this;
00230     }


Member Data Documentation

$_attribute [protected]

Definition at line 47 of file Visibility.php.

const VISIBILITY_BOTH = 4

Definition at line 40 of file Visibility.php.

Definition at line 38 of file Visibility.php.

Definition at line 39 of file Visibility.php.

Definition at line 37 of file Visibility.php.


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

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