1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27: 28: 29: 30: 31: 32: 33:
34: class Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
35: {
36: protected $_attributeTabBlock = 'adminhtml/catalog_product_edit_tab_attributes';
37:
38: public function __construct()
39: {
40: parent::__construct();
41: $this->setId('product_info_tabs');
42: $this->setDestElementId('product_edit_form');
43: $this->setTitle(Mage::helper('catalog')->__('Product Information'));
44: }
45:
46: protected function _prepareLayout()
47: {
48: $product = $this->getProduct();
49:
50: if (!($setId = $product->getAttributeSetId())) {
51: $setId = $this->getRequest()->getParam('set', null);
52: }
53:
54: if ($setId) {
55: $groupCollection = Mage::getResourceModel('eav/entity_attribute_group_collection')
56: ->setAttributeSetFilter($setId)
57: ->setSortOrder()
58: ->load();
59:
60: foreach ($groupCollection as $group) {
61: $attributes = $product->getAttributes($group->getId(), true);
62:
63:
64: foreach ($attributes as $key => $attribute) {
65: if( !$attribute->getIsVisible() ) {
66: unset($attributes[$key]);
67: }
68: }
69:
70: if (count($attributes)==0) {
71: continue;
72: }
73:
74: $this->addTab('group_'.$group->getId(), array(
75: 'label' => Mage::helper('catalog')->__($group->getAttributeGroupName()),
76: 'content' => $this->_translateHtml($this->getLayout()->createBlock($this->getAttributeTabBlock(),
77: 'adminhtml.catalog.product.edit.tab.attributes')->setGroup($group)
78: ->setGroupAttributes($attributes)
79: ->toHtml()),
80: ));
81: }
82:
83: if (Mage::helper('core')->isModuleEnabled('Mage_CatalogInventory')) {
84: $this->addTab('inventory', array(
85: 'label' => Mage::helper('catalog')->__('Inventory'),
86: 'content' => $this->_translateHtml($this->getLayout()
87: ->createBlock('adminhtml/catalog_product_edit_tab_inventory')->toHtml()),
88: ));
89: }
90:
91: 92: 93:
94: if (!Mage::app()->isSingleStoreMode()) {
95: $this->addTab('websites', array(
96: 'label' => Mage::helper('catalog')->__('Websites'),
97: 'content' => $this->_translateHtml($this->getLayout()
98: ->createBlock('adminhtml/catalog_product_edit_tab_websites')->toHtml()),
99: ));
100: }
101:
102: $this->addTab('categories', array(
103: 'label' => Mage::helper('catalog')->__('Categories'),
104: 'url' => $this->getUrl('*/*/categories', array('_current' => true)),
105: 'class' => 'ajax',
106: ));
107:
108: $this->addTab('related', array(
109: 'label' => Mage::helper('catalog')->__('Related Products'),
110: 'url' => $this->getUrl('*/*/related', array('_current' => true)),
111: 'class' => 'ajax',
112: ));
113:
114: $this->addTab('upsell', array(
115: 'label' => Mage::helper('catalog')->__('Up-sells'),
116: 'url' => $this->getUrl('*/*/upsell', array('_current' => true)),
117: 'class' => 'ajax',
118: ));
119:
120: $this->addTab('crosssell', array(
121: 'label' => Mage::helper('catalog')->__('Cross-sells'),
122: 'url' => $this->getUrl('*/*/crosssell', array('_current' => true)),
123: 'class' => 'ajax',
124: ));
125:
126: $storeId = 0;
127: if ($this->getRequest()->getParam('store')) {
128: $storeId = Mage::app()->getStore($this->getRequest()->getParam('store'))->getId();
129: }
130:
131: $alertPriceAllow = Mage::getStoreConfig('catalog/productalert/allow_price');
132: $alertStockAllow = Mage::getStoreConfig('catalog/productalert/allow_stock');
133:
134: if (($alertPriceAllow || $alertStockAllow) && !$product->isGrouped()) {
135: $this->addTab('productalert', array(
136: 'label' => Mage::helper('catalog')->__('Product Alerts'),
137: 'content' => $this->_translateHtml($this->getLayout()
138: ->createBlock('adminhtml/catalog_product_edit_tab_alerts', 'admin.alerts.products')->toHtml())
139: ));
140: }
141:
142: if( $this->getRequest()->getParam('id', false) ) {
143: if (Mage::helper('catalog')->isModuleEnabled('Mage_Review')) {
144: if (Mage::getSingleton('admin/session')->isAllowed('admin/catalog/reviews_ratings')){
145: $this->addTab('reviews', array(
146: 'label' => Mage::helper('catalog')->__('Product Reviews'),
147: 'url' => $this->getUrl('*/*/reviews', array('_current' => true)),
148: 'class' => 'ajax',
149: ));
150: }
151: }
152: if (Mage::helper('catalog')->isModuleEnabled('Mage_Tag')) {
153: if (Mage::getSingleton('admin/session')->isAllowed('admin/catalog/tag')){
154: $this->addTab('tags', array(
155: 'label' => Mage::helper('catalog')->__('Product Tags'),
156: 'url' => $this->getUrl('*/*/tagGrid', array('_current' => true)),
157: 'class' => 'ajax',
158: ));
159:
160: $this->addTab('customers_tags', array(
161: 'label' => Mage::helper('catalog')->__('Customers Tagged Product'),
162: 'url' => $this->getUrl('*/*/tagCustomerGrid', array('_current' => true)),
163: 'class' => 'ajax',
164: ));
165: }
166: }
167:
168: }
169:
170: 171: 172: 173: 174:
175: if (!$product->isGrouped()) {
176: $this->addTab('customer_options', array(
177: 'label' => Mage::helper('catalog')->__('Custom Options'),
178: 'url' => $this->getUrl('*/*/options', array('_current' => true)),
179: 'class' => 'ajax',
180: ));
181: }
182:
183: }
184: else {
185: $this->addTab('set', array(
186: 'label' => Mage::helper('catalog')->__('Settings'),
187: 'content' => $this->_translateHtml($this->getLayout()
188: ->createBlock('adminhtml/catalog_product_edit_tab_settings')->toHtml()),
189: 'active' => true
190: ));
191: }
192: return parent::_prepareLayout();
193: }
194:
195: 196: 197: 198: 199:
200: public function getProduct()
201: {
202: if (!($this->getData('product') instanceof Mage_Catalog_Model_Product)) {
203: $this->setData('product', Mage::registry('product'));
204: }
205: return $this->getData('product');
206: }
207:
208: 209: 210: 211: 212:
213: public function getAttributeTabBlock()
214: {
215: if (is_null(Mage::helper('adminhtml/catalog')->getAttributeTabBlock())) {
216: return $this->_attributeTabBlock;
217: }
218: return Mage::helper('adminhtml/catalog')->getAttributeTabBlock();
219: }
220:
221: public function setAttributeTabBlock($attributeTabBlock)
222: {
223: $this->_attributeTabBlock = $attributeTabBlock;
224: return $this;
225: }
226:
227: 228: 229: 230: 231: 232:
233: protected function _translateHtml($html)
234: {
235: Mage::getSingleton('core/translate_inline')->processResponseBody($html);
236: return $html;
237: }
238: }
239: