Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new useful columns in products tab in category view #2713

Merged
merged 14 commits into from
Apr 26, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ protected function _prepareCollection()
'product_id=entity_id',
'category_id=' . (int) $this->getRequest()->getParam('id', 0),
'left'
);
)
->joinAttribute('status', 'catalog_product/status', 'entity_id', null, 'inner')
->joinAttribute('visibility', 'catalog_product/visibility', 'entity_id', null, 'inner');
$this->setCollection($collection);

if ($this->getCategory()->getProductsReadonly()) {
Expand Down Expand Up @@ -112,35 +114,100 @@ 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('type', [
'header' => Mage::helper('catalog')->__('Type'),
'width' => 100,
'index' => 'type_id',
'type' => 'options',
'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
]);

$sets = Mage::getResourceModel('eav/entity_attribute_set_collection')
->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId())
->load()
->toOptionHash();

$this->addColumn('set_name', [
'header' => Mage::helper('catalog')->__('Attrib. Set Name'),
'width' => 130,
'index' => 'attribute_set_id',
'type' => 'options',
'options' => $sets,
]);

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

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

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

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

$this->addColumn('position', [
'header' => Mage::helper('catalog')->__('Position'),
'width' => '1',
'type' => 'number',
'index' => 'position',
'editable' => !$this->getCategory()->getProductsReadonly()
//'renderer' => 'adminhtml/widget_grid_column_renderer_input'
]);

$this->addColumn('action', [
'header' => Mage::helper('catalog')->__('Action'),
'width' => '50px',
'type' => 'action',
'getter' => 'getId',
'actions' => [
[
'caption' => Mage::helper('catalog')->__('Edit'),
'id' => 'editlink',
'field' => 'id',
'onclick' => "popWin(this.href,'win','width=1000,height=700,resizable=1,scrollbars=1');return false;",
'url' => [
'base' => 'adminhtml/catalog_product/edit',
'params' => [
'store' => $this->getRequest()->getParam('store'),
'popup' => 1
],
],
],
],
'filter' => false,
'sortable' => false,
'index' => 'stores',
]);

return parent::_prepareColumns();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@
<script type="text/javascript">
var added = false;
function addProduct(closeAfter) {
if(window.opener!=null && !added) {
<?php if($this->isEdit()): ?>
window.opener.superProduct.updateProduct(<?php echo $this->getProductId() ?>, <?php echo $this->getAttributesJson(); ?>);
<?php else: ?>
window.opener.superProduct.addNewProduct(<?php echo $this->getProductId() ?>, <?php echo $this->getAttributesJson(); ?>);
window.opener.superProduct.showNoticeMessage();
<?php endif ?>
added = true;
if(window.opener != null && !added) {
if (window.opener.superProduct) {
<?php if($this->isEdit()): ?>
window.opener.superProduct.updateProduct(<?php echo $this->getProductId() ?>, <?php echo $this->getAttributesJson(); ?>);
<?php else: ?>
window.opener.superProduct.addNewProduct(<?php echo $this->getProductId() ?>, <?php echo $this->getAttributesJson(); ?>);
window.opener.superProduct.showNoticeMessage();
<?php endif ?>
added = true;
} else if (window.opener.catalog_category_productsJsObject) {
window.opener.catalog_category_productsJsObject.reload(null);
}
}

if(closeAfter)
Expand Down
Loading