Mage_Catalog_Model_Product_Link Class Reference

Inheritance diagram for Mage_Catalog_Model_Product_Link:

Mage_Core_Model_Abstract Varien_Object

List of all members.

Public Member Functions

 useRelatedLinks ()
 useGroupedLinks ()
 useUpSellLinks ()
 useCrossSellLinks ()
 getAttributeTypeTable ($type)
 getProductCollection ()
 getLinkCollection ()
 getAttributes ($type=null)
 saveProductRelations ($product)
 saveGroupedLinks ($product)

Public Attributes

const LINK_TYPE_RELATED = 1
const LINK_TYPE_GROUPED = 3
const LINK_TYPE_UPSELL = 4
const LINK_TYPE_CROSSSELL = 5

Protected Member Functions

 _construct ()

Protected Attributes

 $_attributeCollection = null


Detailed Description

Definition at line 35 of file Link.php.


Member Function Documentation

_construct (  )  [protected]

Initialize resource

Reimplemented from Varien_Object.

Definition at line 47 of file Link.php.

00048     {
00049         $this->_init('catalog/product_link');
00050     }

getAttributes ( type = null  ) 

Definition at line 110 of file Link.php.

00111     {
00112         if (is_null($type)) {
00113             $type = $this->getLinkTypeId();
00114         }
00115         return $this->_getResource()->getAttributesByType($type);
00116     }

getAttributeTypeTable ( type  ) 

Retrieve table name for attribute type

Parameters:
string $type
Returns:
string

Definition at line 85 of file Link.php.

00086     {
00087         return $this->_getResource()->getAttributeTypeTable($type);
00088     }

getLinkCollection (  ) 

Retrieve link collection

Definition at line 103 of file Link.php.

00104     {
00105         $collection = Mage::getResourceModel('catalog/product_link_collection')
00106             ->setLinkModel($this);
00107         return $collection;
00108     }

getProductCollection (  ) 

Retrieve linked product collection

Definition at line 93 of file Link.php.

00094     {
00095         $collection = Mage::getResourceModel('catalog/product_link_product_collection')
00096             ->setLinkModel($this);
00097         return $collection;
00098     }

saveGroupedLinks ( product  ) 

Definition at line 141 of file Link.php.

00142     {
00143         $data = $product->getGroupedLinkData();
00144         if (!is_null($data)) {
00145             $this->_getResource()->saveProductLinks($product, $data, self::LINK_TYPE_GROUPED);
00146         }
00147         return $this;
00148     }

saveProductRelations ( product  ) 

Save data for product relations

Parameters:
Mage_Catalog_Model_Product $product
Returns:
Mage_Catalog_Model_Product_Link

Definition at line 124 of file Link.php.

00125     {
00126         $data = $product->getRelatedLinkData();
00127         if (!is_null($data)) {
00128             $this->_getResource()->saveProductLinks($product, $data, self::LINK_TYPE_RELATED);
00129         }
00130         $data = $product->getUpSellLinkData();
00131         if (!is_null($data)) {
00132             $this->_getResource()->saveProductLinks($product, $data, self::LINK_TYPE_UPSELL);
00133         }
00134         $data = $product->getCrossSellLinkData();
00135         if (!is_null($data)) {
00136             $this->_getResource()->saveProductLinks($product, $data, self::LINK_TYPE_CROSSSELL);
00137         }
00138         return $this;
00139     }

useCrossSellLinks (  ) 

Returns:
Mage_Catalog_Model_Product_Link

Definition at line 73 of file Link.php.

00074     {
00075         $this->setLinkTypeId(self::LINK_TYPE_CROSSSELL);
00076         return $this;
00077     }

useGroupedLinks (  ) 

Definition at line 58 of file Link.php.

00059     {
00060         $this->setLinkTypeId(self::LINK_TYPE_GROUPED);
00061         return $this;
00062     }

useRelatedLinks (  ) 

Definition at line 52 of file Link.php.

00053     {
00054         $this->setLinkTypeId(self::LINK_TYPE_RELATED);
00055         return $this;
00056     }

useUpSellLinks (  ) 

Definition at line 64 of file Link.php.

00065     {
00066         $this->setLinkTypeId(self::LINK_TYPE_UPSELL);
00067         return $this;
00068     }


Member Data Documentation

$_attributeCollection = null [protected]

Definition at line 42 of file Link.php.

Definition at line 40 of file Link.php.

const LINK_TYPE_GROUPED = 3

Definition at line 38 of file Link.php.

const LINK_TYPE_RELATED = 1

Definition at line 37 of file Link.php.

const LINK_TYPE_UPSELL = 4

Definition at line 39 of file Link.php.


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

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