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 class Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
00035 {
00036 protected $_attributeTabBlock = 'adminhtml/catalog_product_edit_tab_attributes';
00037
00038 public function __construct()
00039 {
00040 parent::__construct();
00041 $this->setId('product_info_tabs');
00042 $this->setDestElementId('product_edit_form');
00043 $this->setTitle(Mage::helper('catalog')->__('Product Information'));
00044 }
00045
00046 protected function _prepareLayout()
00047 {
00048 $product = $this->getProduct();
00049
00050 if (!($setId = $product->getAttributeSetId())) {
00051 $setId = $this->getRequest()->getParam('set', null);
00052 }
00053
00054 if ($setId) {
00055 $groupCollection = Mage::getResourceModel('eav/entity_attribute_group_collection')
00056 ->setAttributeSetFilter($setId)
00057 ->load();
00058
00059 foreach ($groupCollection as $group) {
00060 $attributes = $product->getAttributes($group->getId(), true);
00061
00062
00063 foreach ($attributes as $key => $attribute) {
00064 if( !$attribute->getIsVisible() ) {
00065 unset($attributes[$key]);
00066 }
00067 }
00068
00069 if (count($attributes)==0) {
00070 continue;
00071 }
00072
00073 $this->addTab('group_'.$group->getId(), array(
00074 'label' => Mage::helper('catalog')->__($group->getAttributeGroupName()),
00075 'content' => $this->getLayout()->createBlock($this->getAttributeTabBlock())
00076 ->setGroup($group)
00077 ->setGroupAttributes($attributes)
00078 ->toHtml(),
00079 ));
00080 }
00081
00082 $this->addTab('inventory', array(
00083 'label' => Mage::helper('catalog')->__('Inventory'),
00084 'content' => $this->getLayout()->createBlock('adminhtml/catalog_product_edit_tab_inventory')->toHtml(),
00085 ));
00086
00087
00088
00089
00090
00091 if (!Mage::app()->isSingleStoreMode()) {
00092 $this->addTab('websites', array(
00093 'label' => Mage::helper('catalog')->__('Websites'),
00094 'content' => $this->getLayout()->createBlock('adminhtml/catalog_product_edit_tab_websites')->toHtml(),
00095 ));
00096 }
00097
00098 $this->addTab('categories', array(
00099 'label' => Mage::helper('catalog')->__('Categories'),
00100 'url' => $this->getUrl('*/*/categories', array('_current' => true)),
00101 'class' => 'ajax',
00102 ));
00103
00104 $this->addTab('related', array(
00105 'label' => Mage::helper('catalog')->__('Related Products'),
00106 'url' => $this->getUrl('*/*/related', array('_current' => true)),
00107 'class' => 'ajax',
00108 ));
00109
00110 $this->addTab('upsell', array(
00111 'label' => Mage::helper('catalog')->__('Up-sells'),
00112 'url' => $this->getUrl('*/*/upsell', array('_current' => true)),
00113 'class' => 'ajax',
00114 ));
00115
00116 $this->addTab('crosssell', array(
00117 'label' => Mage::helper('catalog')->__('Cross-sells'),
00118 'url' => $this->getUrl('*/*/crosssell', array('_current' => true)),
00119 'class' => 'ajax',
00120 ));
00121
00122 $storeId = 0;
00123 if ($this->getRequest()->getParam('store')) {
00124 $storeId = Mage::app()->getStore($this->getRequest()->getParam('store'))->getId();
00125 }
00126
00127 $alertPriceAllow = Mage::getStoreConfig('catalog/productalert/allow_price');
00128 $alertStockAllow = Mage::getStoreConfig('catalog/productalert/allow_stock');
00129
00130 if ($alertPriceAllow || $alertStockAllow) {
00131 $this->addTab('productalert', array(
00132 'label' => Mage::helper('catalog')->__('Product Alerts'),
00133 'content' => $this->getLayout()->createBlock('adminhtml/catalog_product_edit_tab_alerts', 'admin.alerts.products')->toHtml()
00134 ));
00135 }
00136
00137 if( $this->getRequest()->getParam('id', false) ) {
00138 $this->addTab('reviews', array(
00139 'label' => Mage::helper('catalog')->__('Product Reviews'),
00140 'url' => $this->getUrl('*/*/reviews', array('_current' => true)),
00141 'class' => 'ajax',
00142 ));
00143
00144 $this->addTab('tags', array(
00145 'label' => Mage::helper('catalog')->__('Product Tags'),
00146 'url' => $this->getUrl('*/*/tagGrid', array('_current' => true)),
00147 'class' => 'ajax',
00148 ));
00149
00150 $this->addTab('customers_tags', array(
00151 'label' => Mage::helper('catalog')->__('Customers Tagged Product'),
00152 'url' => $this->getUrl('*/*/tagCustomerGrid', array('_current' => true)),
00153 'class' => 'ajax',
00154 ));
00155 }
00156
00157
00158
00159
00160
00161
00162 if ($this->getProduct()->getTypeId() != Mage_Catalog_Model_Product_Type::TYPE_GROUPED) {
00163 $this->addTab('customer_options', array(
00164 'label' => Mage::helper('catalog')->__('Custom Options'),
00165 'url' => $this->getUrl('*/*/options', array('_current' => true)),
00166 'class' => 'ajax',
00167 ));
00168 }
00169
00170 }
00171 else {
00172 $this->addTab('set', array(
00173 'label' => Mage::helper('catalog')->__('Settings'),
00174 'content' => $this->getLayout()->createBlock('adminhtml/catalog_product_edit_tab_settings')->toHtml(),
00175 'active' => true
00176 ));
00177 }
00178 return parent::_prepareLayout();
00179 }
00180
00181
00182
00183
00184
00185
00186 public function getProduct()
00187 {
00188 if (!($this->getData('product') instanceof Mage_Catalog_Model_Product)) {
00189 $this->setData('product', Mage::registry('product'));
00190 }
00191 return $this->getData('product');
00192 }
00193
00194
00195
00196
00197
00198
00199 public function getAttributeTabBlock()
00200 {
00201 if (is_null(Mage::helper('adminhtml/catalog')->getAttributeTabBlock())) {
00202 return $this->_attributeTabBlock;
00203 }
00204 return Mage::helper('adminhtml/catalog')->getAttributeTabBlock();
00205 }
00206
00207 public function setAttributeTabBlock($attributeTabBlock)
00208 {
00209 $this->_attributeTabBlock = $attributeTabBlock;
00210 return $this;
00211 }
00212 }