Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,24 @@ protected function _prepareCollection()
if ($this->getCategory()->getId()) {
$this->setDefaultFilter(['in_category' => 1]);
}

$store = (int) $this->getRequest()->getParam('store', 0);
$collection = Mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect('name')
->addAttributeToSelect('sku')
->addStoreFilter($store)
->addAttributeToSelect('price')
->addStoreFilter($this->getRequest()->getParam('store'))
->joinField(
'position',
'catalog/category_product',
'position',
'product_id=entity_id',
'category_id=' . (int) $this->getRequest()->getParam('id', 0),
'left'
);
)
->joinAttribute('name', 'catalog_product/name', 'entity_id', null, 'left', $store)
->joinAttribute('price', 'catalog_product/price', 'entity_id', null, 'left', $store)
->joinAttribute('status', 'catalog_product/status', 'entity_id', null, 'left', $store)
->joinAttribute('visibility', 'catalog_product/visibility', 'entity_id', null, 'left', $store);

$this->setCollection($collection);

if ($this->getCategory()->getProductsReadonly()) {
Expand Down Expand Up @@ -113,28 +118,49 @@ protected function _prepareColumns()
'index' => 'entity_id'
]);
}

$this->addColumn('entity_id', [
'header' => Mage::helper('catalog')->__('ID'),
'sortable' => true,
'width' => '60',
'index' => 'entity_id'
]);

$this->addColumn('name', [
'header' => Mage::helper('catalog')->__('Name'),
'index' => 'name'
]);

$this->addColumn('sku', [
'header' => Mage::helper('catalog')->__('SKU'),
'width' => '80',
'index' => 'sku'
]);

$this->addColumn('price', [
'header' => Mage::helper('catalog')->__('Price'),
'type' => 'currency',
'type' => 'currency',
'width' => '1',
'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
'index' => 'price'
]);

$this->addColumn('visibility', [
'header' => Mage::helper('catalog')->__('Visibility'),
'width' => '70',
'index' => 'visibility',
'type' => 'options',
'options' => Mage::getModel('catalog/product_visibility')->getOptionArray()
]);

$this->addColumn('status', [
'header' => Mage::helper('catalog')->__('Status'),
'width' => '70',
'index' => 'status',
'type' => 'options',
'options' => Mage::getSingleton('catalog/product_status')->getOptionArray()
]);

$this->addColumn('position', [
'header' => Mage::helper('catalog')->__('Position'),
'width' => '1',
Expand All @@ -144,15 +170,43 @@ protected function _prepareColumns()
//'renderer' => 'adminhtml/widget_grid_column_renderer_input'
]);

$this->addColumn('action', [
'header' => Mage::helper('catalog')->__('Action'),
'type' => 'action',
'getter' => 'getId',
'actions' => [
[
'caption' => Mage::helper('catalog')->__('Edit'),
'url' => [
'base' => '*/catalog_product/edit',
'params' => [
'store' => (int) $this->getRequest()->getParam('store', 0),
'popup' => 1,
'popin' => 0
]
],
'field' => 'id',
'onclick' => 'superProduct = new Product.EditWin('.$this->getJsObjectName().'); superProduct.createPopup(this.href); superProduct.links = '.$this->getJsObjectProductsName().'; return false;'
]
],
'filter' => false,
'sortable' => false
]);

return parent::_prepareColumns();
}

public function getJsObjectProductsName()
{
return 'categoryProducts';
}

/**
* @return string
*/
public function getGridUrl()
{
return $this->getUrl('*/*/grid', ['_current' => true]);
return $this->getUrl('*/*/grid', ['_current' => true, 'store' => (int) $this->getRequest()->getParam('store', 0)]);
}

/**
Expand All @@ -161,8 +215,8 @@ public function getGridUrl()
*/
protected function _getSelectedProducts()
{
$products = $this->getRequest()->getPost('selected_products');
if (is_null($products)) {
$products = $this->getProductsCategory();
if (!is_array($products)) {
$products = $this->getCategory()->getProductsPosition();
return array_keys($products);
}
Expand Down
50 changes: 30 additions & 20 deletions app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,29 @@ protected function _prepareLayout()
'back_button',
$this->getLayout()->createBlock('adminhtml/widget_button')
->setData([
'label' => Mage::helper('catalog')->__('Back'),
'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getUrl('*/*/', ['store' => $this->getRequest()->getParam('store', 0)])),
'class' => 'back'
'label' => Mage::helper('catalog')->__('Back'),
'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getUrl('*/*/', ['store' => $this->getRequest()->getParam('store', 0)])),
'class' => 'back'
])
);
} elseif (!$this->getRequest()->getParam('popin')) {
$this->setChild(
'back_button',
$this->getLayout()->createBlock('adminhtml/widget_button')
->setData([
'label' => Mage::helper('catalog')->__('Close Window'),
'onclick' => 'window.close()',
'class' => 'cancel'
])
);
} else {
$this->setChild(
'back_button',
$this->getLayout()->createBlock('adminhtml/widget_button')
->setData([
'label' => Mage::helper('catalog')->__('Close Window'),
'onclick' => 'window.close()',
'class' => 'cancel'
'label' => Mage::helper('catalog')->__('Close Window'),
'onclick' => 'window.parent.superProduct.closePopup()',
'class' => 'cancel'
])
);
}
Expand All @@ -72,18 +82,18 @@ protected function _prepareLayout()
'reset_button',
$this->getLayout()->createBlock('adminhtml/widget_button')
->setData([
'label' => Mage::helper('catalog')->__('Reset'),
'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getUrl('*/*/*', ['_current' => true]))
'label' => Mage::helper('catalog')->__('Reset'),
'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getUrl('*/*/*', ['_current' => true]))
])
);

$this->setChild(
'save_button',
$this->getLayout()->createBlock('adminhtml/widget_button')
->setData([
'label' => Mage::helper('catalog')->__('Save'),
'onclick' => 'productForm.submit()',
'class' => 'save'
'label' => Mage::helper('catalog')->__('Save'),
'onclick' => 'productForm.submit()',
'class' => 'save'
])
);
}
Expand All @@ -94,9 +104,9 @@ protected function _prepareLayout()
'save_and_edit_button',
$this->getLayout()->createBlock('adminhtml/widget_button')
->setData([
'label' => Mage::helper('catalog')->__('Save and Continue Edit'),
'onclick' => Mage::helper('core/js')->getSaveAndContinueEditJs($this->getSaveAndContinueUrl()),
'class' => 'save'
'label' => Mage::helper('catalog')->__('Save and Continue Edit'),
'onclick' => Mage::helper('core/js')->getSaveAndContinueEditJs($this->getSaveAndContinueUrl()),
'class' => 'save'
])
);
}
Expand All @@ -105,9 +115,9 @@ protected function _prepareLayout()
'delete_button',
$this->getLayout()->createBlock('adminhtml/widget_button')
->setData([
'label' => Mage::helper('catalog')->__('Delete'),
'onclick' => Mage::helper('core/js')->getConfirmSetLocationJs($this->getDeleteUrl()),
'class' => 'delete'
'label' => Mage::helper('catalog')->__('Delete'),
'onclick' => Mage::helper('core/js')->getConfirmSetLocationJs($this->getDeleteUrl()),
'class' => 'delete'
])
);
}
Expand All @@ -117,9 +127,9 @@ protected function _prepareLayout()
'duplicate_button',
$this->getLayout()->createBlock('adminhtml/widget_button')
->setData([
'label' => Mage::helper('catalog')->__('Duplicate'),
'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getDuplicateUrl()),
'class' => 'add'
'label' => Mage::helper('catalog')->__('Duplicate'),
'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getDuplicateUrl()),
'class' => 'add'
])
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,13 @@ protected function _prepareColumns()
[
'header' => Mage::helper('catalog')->__('Action'),
'type' => 'action',
'getter' => 'getId',
'getter' => 'getId',
'actions' => [
[
'caption' => Mage::helper('catalog')->__('Edit'),
'url' => $this->getEditParamsForAssociated(),
'field' => 'id',
'onclick' => 'superProduct.createPopup(this.href);return false;'
'onclick' => 'superProduct.createPopup(this.href);return false;'
]
],
'filter' => false,
Expand All @@ -283,10 +283,12 @@ protected function _prepareColumns()
public function getEditParamsForAssociated()
{
return [
'base' => '*/*/edit',
'params' => [
'base' => '*/*/edit',
'params' => [
'required' => $this->_getRequiredAttributesIds(),
'store' => (int) $this->getRequest()->getParam('store', 0),
'popup' => 1,
'popin' => 0,
'product' => $this->_getProduct()->getId()
]
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function editAction()
$_prevStoreId = Mage::getSingleton('admin/session')
->getLastViewedStore(true);

if (!empty($_prevStoreId) && !$this->getRequest()->getQuery('isAjax')) {
if (is_numeric($_prevStoreId) && !$this->getRequest()->getQuery('isAjax')) {
$params['store'] = $_prevStoreId;
$redirect = true;
}
Expand Down Expand Up @@ -164,7 +164,7 @@ public function editAction()
}

Mage::getSingleton('admin/session')
->setLastViewedStore($this->getRequest()->getParam('store'));
->setLastViewedStore($storeId);
Mage::getSingleton('admin/session')
->setLastEditedCategory($category->getId());
$this->loadLayout();
Expand Down Expand Up @@ -423,6 +423,7 @@ public function gridAction()
}
$this->getResponse()->setBody(
$this->getLayout()->createBlock('adminhtml/catalog_category_tab_product', 'category.product.grid')
->setProductsCategory($this->getRequest()->getPost('selected_products', []))
->toHtml()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,14 @@ public function editAction()
$block->setStoreId($product->getStoreId());
}

if ($this->getRequest()->getParam('popin')) {
/** @var Mage_Adminhtml_Block_Page $root */
$root = $this->getLayout()->getBlock('root');
if ($root) {
$root->addBodyClass('popup-nohead-nofoot');
}
}

$this->renderLayout();
}

Expand Down
Loading