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_Adminhtml_Helper_Catalog_Product_Edit_Action_Attribute extends Mage_Core_Helper_Data
00036 {
00037
00038
00039
00040
00041
00042 protected $_products;
00043
00044
00045
00046
00047
00048
00049 protected $_productsNotInStore;
00050
00051
00052
00053
00054
00055
00056 protected $_attributes;
00057
00058
00059
00060
00061
00062
00063
00064 protected $_excludedAttributes = array('url_key');
00065
00066
00067
00068
00069
00070
00071 public function getProducts()
00072 {
00073 if (is_null($this->_products)) {
00074 $productsIds = $this->getProductIds();
00075
00076 if(!is_array($productsIds)) {
00077 $productsIds = array(0);
00078 }
00079
00080 $this->_products = Mage::getResourceModel('catalog/product_collection')
00081 ->setStoreId($this->getSelectedStoreId())
00082 ->addIdFilter($productsIds);
00083
00084
00085 }
00086
00087 return $this->_products;
00088 }
00089
00090
00091
00092
00093
00094
00095 public function getProductIds()
00096 {
00097 $session = Mage::getSingleton('adminhtml/session');
00098
00099 if ($this->_getRequest()->isPost() && $this->_getRequest()->getActionName()=='edit') {
00100 $session->setProductIds($this->_getRequest()->getParam('product', null));
00101 }
00102
00103 return $session->getProductIds();
00104 }
00105
00106
00107
00108
00109
00110
00111 public function getSelectedStoreId()
00112 {
00113 return (int) $this->_getRequest()->getParam('store', 0);
00114 }
00115
00116
00117
00118
00119
00120
00121 public function getProductsSetIds()
00122 {
00123 return $this->getProducts()->getSetIds();
00124 }
00125
00126
00127
00128
00129
00130
00131 public function getAttributes()
00132 {
00133 if (is_null($this->_attributes)) {
00134 $this->_attributes = $this->getProducts()->getEntity()->getEntityType()->getAttributeCollection()
00135 ->addIsNotUniqueFilter()
00136 ->setInAllAttributeSetsFilter($this->getProductsSetIds());
00137
00138 foreach ($this->_excludedAttributes as $attributeCode) {
00139 $this->_attributes->addFieldToFilter('attribute_code', array('neq'=>$attributeCode));
00140 }
00141
00142 $this->_attributes->load();
00143 foreach($this->_attributes as $attribute) {
00144 $attribute->setEntity($this->getProducts()->getEntity());
00145 }
00146 }
00147
00148 return $this->_attributes;
00149 }
00150
00151
00152
00153
00154
00155
00156 public function getProductsNotInStoreIds()
00157 {
00158 if (is_null($this->_productsNotInStore)) {
00159 $this->_productsNotInStoreIds = array();
00160
00161
00162
00163
00164
00165
00166 }
00167
00168 return $this->_productsNotInStoreIds;
00169 }
00170
00171 }