Mage_Catalog_Model_Product_Website Class Reference

Inheritance diagram for Mage_Catalog_Model_Product_Website:

Mage_Core_Model_Abstract Varien_Object

List of all members.

Public Member Functions

 removeProducts ($websiteIds, $productIds)
 addProducts ($websiteIds, $productIds)
 getWebsites ($productIds)

Protected Member Functions

 _construct ()
 _getResource ()


Detailed Description

Definition at line 35 of file Website.php.


Member Function Documentation

_construct (  )  [protected]

Initialize resource model

Reimplemented from Varien_Object.

Definition at line 41 of file Website.php.

00042     {
00043         $this->_init('catalog/product_website');
00044     }

_getResource (  )  [protected]

Retrieve Resource instance wrapper

Returns:
Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Website

Reimplemented from Mage_Core_Model_Abstract.

Definition at line 51 of file Website.php.

00052     {
00053         return parent::_getResource();
00054     }

addProducts ( websiteIds,
productIds 
)

Add products to websites

Parameters:
array $websiteIds
array $productIds
Returns:
Mage_Catalog_Model_Product_Website

Definition at line 91 of file Website.php.

00092     {
00093         try {
00094             $this->_getResource()->addProducts($websiteIds, $productIds);
00095             Mage::getResourceModel('catalog/category')->refreshProductIndex(
00096                 array(), $productIds
00097             );
00098             Mage::dispatchEvent('catalog_product_website_update', array(
00099                 'website_ids'   => $websiteIds,
00100                 'product_ids'   => $productIds,
00101                 'action'        => 'add'
00102             ));
00103         }
00104         catch (Exception $e) {
00105             Mage::throwException(
00106                 Mage::helper('catalog')->__('There was an error while adding products to websites')
00107             );
00108         }
00109         return $this;
00110     }

getWebsites ( productIds  ) 

Retrieve product websites Return array with key as product ID and value array of websites

Parameters:
int|array $productIds
Returns:
array

Definition at line 119 of file Website.php.

00120     {
00121         return $this->_getResource()->getWebsites($productIds);
00122     }

removeProducts ( websiteIds,
productIds 
)

Removes products from websites

Parameters:
array $websiteIds
array $productIds
Returns:
Mage_Catalog_Model_Product_Website

Definition at line 63 of file Website.php.

00064     {
00065         try {
00066             $this->_getResource()->removeProducts($websiteIds, $productIds);
00067             Mage::getResourceModel('catalog/category')->refreshProductIndex(
00068                 array(), $productIds
00069             );
00070             Mage::dispatchEvent('catalog_product_website_update', array(
00071                 'website_ids'   => $websiteIds,
00072                 'product_ids'   => $productIds,
00073                 'action'        => 'remove'
00074             ));
00075         }
00076         catch (Exception $e) {
00077             Mage::throwException(
00078                 Mage::helper('catalog')->__('There was an error while removing products from websites')
00079             );
00080         }
00081         return $this;
00082     }


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