Public Member Functions | |
setLinkModel ($linkModel) | |
getLinkModel () | |
setProduct ($product) | |
getProduct () | |
addLinkTypeIdFilter () | |
addProductIdFilter () | |
joinAttributes () | |
Protected Member Functions | |
_construct () | |
Protected Attributes | |
$_product | |
$_linkModel | |
$_linkTypeId |
Definition at line 35 of file Collection.php.
_construct | ( | ) | [protected] |
Initialization here
Reimplemented from Mage_Core_Model_Mysql4_Collection_Abstract.
Definition at line 42 of file Collection.php.
00043 { 00044 $this->_init('catalog/product_link'); 00045 }
addLinkTypeIdFilter | ( | ) |
Add link's type to filter
Definition at line 99 of file Collection.php.
00100 { 00101 if ($this->_linkTypeId) { 00102 $this->addFieldToFilter("link_type_id", $this->_linkTypeId); 00103 } 00104 return $this; 00105 }
addProductIdFilter | ( | ) |
Add product to filter
Definition at line 112 of file Collection.php.
00113 { 00114 if ($this->getProduct() && $this->getProduct()->getId()) { 00115 $this->addFieldToFilter("product_id", $this->getProduct()->getId()); 00116 } 00117 return $this; 00118 }
getLinkModel | ( | ) |
Retrieve collection link model
Definition at line 67 of file Collection.php.
getProduct | ( | ) |
Retrieve collection base product object
Definition at line 89 of file Collection.php.
joinAttributes | ( | ) |
Join attributes
Definition at line 125 of file Collection.php.
00126 { 00127 if ($this->getLinkModel()) { 00128 $attributes = $this->getLinkModel()->getAttributes(); 00129 $attributesByType = array(); 00130 foreach ($attributes as $attribute) { 00131 $table = $this->getLinkModel()->getAttributeTypeTable($attribute['type']); 00132 $alias = 'link_attribute_'.$attribute['code'].'_'.$attribute['type']; 00133 $this->getSelect()->joinLeft( 00134 array($alias => $table), 00135 $alias.'.link_id=main_table.link_id AND '.$alias.'.product_link_attribute_id='.$attribute['id'], 00136 array($attribute['code'] => 'value') 00137 ); 00138 } 00139 } 00140 return $this; 00141 }
setLinkModel | ( | $ | linkModel | ) |
Declare link model and initialize type attributes join
Mage_Catalog_Model_Product_Link | $linkModel |
Definition at line 53 of file Collection.php.
00054 { 00055 $this->_linkModel = $linkModel; 00056 if ($linkModel->getLinkTypeId()) { 00057 $this->_linkTypeId = $linkModel->getLinkTypeId(); 00058 } 00059 return $this; 00060 }
setProduct | ( | $ | product | ) |
Initialize collection parent product and add limitation join
Mage_Catalog_Model_Product | $product |
Definition at line 78 of file Collection.php.
$_linkModel [protected] |
Definition at line 39 of file Collection.php.
$_linkTypeId [protected] |
Definition at line 40 of file Collection.php.
$_product [protected] |
Definition at line 38 of file Collection.php.