00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 class Mage_Catalog_Model_Product_Website extends Mage_Core_Model_Abstract
00036 {
00037
00038
00039
00040
00041 protected function _construct()
00042 {
00043 $this->_init('catalog/product_website');
00044 }
00045
00046
00047
00048
00049
00050
00051 protected function _getResource()
00052 {
00053 return parent::_getResource();
00054 }
00055
00056
00057
00058
00059
00060
00061
00062
00063 public function removeProducts($websiteIds, $productIds)
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 }
00083
00084
00085
00086
00087
00088
00089
00090
00091 public function addProducts($websiteIds, $productIds)
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 }
00111
00112
00113
00114
00115
00116
00117
00118
00119 public function getWebsites($productIds)
00120 {
00121 return $this->_getResource()->getWebsites($productIds);
00122 }
00123 }