Magento Custom Grid delete action not working - php

I have Magento custom grid that is showing my list of products I want to remove my product when someone click on delete action. I have written my action code that is below but it is not working everytime when I click on delete it shows me 404 page when using url (*/*/delete) and when I changed the url to (*/*/../../admin/catalog_product/delete) it will go to dashboard page but didn't delete my product:
$this->addColumn('action',
array(
'header' => 'Action',
'width' => '100px',
'type' => 'action',
'getter' => 'getId',
'actions' => array(
array(
'url' => array('base'=> '*/*/edit'),
'field' => 'id'
)
)
)
)
Any solution for my this problem will really helpfull for me.

I think problem is on url making,try to make url as follow in actions.
Note : Replace param_id as per your url perameter and module name as per your module name in helper.
'actions' => array(
array(
'caption' => Mage::helper('module_name')->__('Edit'),
'url' => array(
'base'=>'*/*/edit',
'params'=> array('id'=>$this->getRequest()->getParam('param_id'))
),'field' => 'id'
),
array(
'caption' => Mage::helper('module_name')->__('Delete'),
'url' => array(
'base'=>'*/*/delete',
'params'=> array('id'=>$this->getRequest()->getParam('param_id'))
),'field' => 'id'
)
),

You haven't created a delete action, try modify the above code to:
$this->addColumn('action',
array(
'header' => 'Action',
'width' => '100px',
'type' => 'action',
'getter' => 'getId',
'actions' => array(
array(
'url' => array('base'=> '*/*/edit'),
'field' => 'id'
),
array(
'url' => array('base'=> '*/*/delete'),
'field' => 'id'
)
)

Related

Modifying metabox custom field through myphpadmin causing wordpress to show blank

so basically on my wordpress site, i link images and i recently changed my image domain name, so i went into phpmyadmin and typed:
UPDATE `wp_postmeta` SET `meta_value` = replace(meta_value, 'old-domain.com', 'new-domain.com')
and my mysql/phpmyadmin, its all updated to the new domain, but on wordpress, the custom field hasnt picked up the new details and is left blank.
this is my array for the custom field:
'title' => 'Embed Image',
'pages' => array( 'post' ),
'tabs' => array(
'input-version' => array(
'label' => 'Input Version',
'icon' => 'dashicons-admin-customizer',
),
'tab_style' => 'default',
'fields' => array(
array(
'id' => 'ab_embedgroup',
'type' => 'group',
'clone' => true,
'sort_clone' => true,
'save_state' => true,
'desc' => '<b style="color:red;">Insert embed code</b>',
'tab' => 'input-version',
'fields' => array(
array(
'name' => 'Host Name',
'id' => 'ab_hostname',
'type' => 'text',
),
array(
'name' => 'IMEmbed',
'id' => 'ab_embed',
'type' => 'textarea',
'sanitize_callback' => 'none',```
cleared cache, restarted VPS, tried it all, just cant understand why it wont pick it up.
am i editing it incorrectly? Cant do it one by one because its a few thousand images.

How to show a grid / table in a tab section that will be displayed in in the admin section of prestashop 1.6.x

I want to show a grid or editable table in my tab in the admin section
I managed to do the module and three tabs are been displayed .In one of the tab i want to show a editable grid i.e in the CHECKS tab
As shown in the below image,in the chek tab section i want to show a grid
In the constructor of my admin controller of my module ()
ie in addhealthcheckconfig\controllers\admin\HealthCheckConfigController.php
I am setting the field options to populate the tab ,below is my code:
$this->fields_options = array(
'appearance' => array(
'title' => $this->l('Manage your Health Check '),
'icon' => 'icon-html5',
'tabs' => array(
'TAB1' => $this->l('SUPPORT_GROUPS'),
'TAB2' => $this->l('CHECKS'),
'TAB3' => $this->l('REPORT RECIPIENTS'),
),
'fields' => array(
'SUPPORT_GROUPS' => array(
'title' => $this->l('SUPPORT GROUPS'),
'hint' => $this->l('Manage your Support Groups here'),
'type' => 'fields_list',
'name' => 'PS_LOGO',
'tab' => 'TAB1'
),
'CHECKS' => array(
'title' => $this->l('LIST OF AVAILABLE CHECKS '),
'hint' => $this->l('List of Available checks will be displayed here !!'),
'type' => 'text',
'list' => $this->fields_list = array(
'code' => array(
'title' => $this->l('code'),
'align' => 'text-center',
'remove_onclick' => true,
'search' => false,
),
'description' => array(
'title' => $this->l('description'),
'align' => 'text-center',
'remove_onclick' => true,
'search' => false,
),
'category' => array(
'title' => $this->l('category'),
'align' => 'text-center',
'remove_onclick' => true,
'search' => false,
),
),
'tab' => 'TAB2'
),
'REPORT_RECIPIENTS' => array(
'title' => $this->l('REPORT RECIPIENTS '),
'hint' => $this->l('List of Available checks will be displayed here !!'),
'tab' => 'TAB3'
),
) ));
In the TAB2 Section i am not sure what i need to put in the 'type' section , I tried with list , but yet I can not achieve what I am trying to do , also i am not sure how to assign the $this->fields_list to that type correctly
How to achieve this editable db grid in my tab ?

assign id to select box magento admin custom grid

I have custom grid on my magento admin panel where I want to add product id as a css id to every select box I have tried 'column_css_class' => 'id' but this add class to every select box with id word not its value how can i do this
$this->addColumn('icon',
array(
'header' => 'Icon',
'width' => '100px',
'type' => 'action',
'getter' => 'getId',
'index' => 'stores',
'column_css_class' => 'id',
'actions' => array(
array(
'caption' => 'Enable',
'url' => array(
'base'=>'*/*/enable'
),'field' => 'id'
),
array(
'caption' => 'Disable',
'url' => array(
'base'=>'*/*/disable'
),
'field' => 'id'
)
)
));
If you have a product object says $oProduct,
You can change your code so that instead of
'column_css_class' => 'id'
You would have:
'column_css_class' => $oProduct->getId()
Also using product id is not a good idea, use SKU instead.

Yii bootstrap, adding id and class to TbBootstrap

i'm using PHP Yii framework, and came across a problem regarding adding Id and other attributes to a tab. I'm using yii bootstrap by the way as extension:
$tabs = array(
'item1' => array(
'label' => 'label1',
'content' => $content1,
),
'preview' => array(
'label' => 'Preview',
),
);
$this->widget('bootstrap.widgets.TbWizard',
array(
'id' => 'harvest-tabs',
'type' => 'tabs',
'tabs' => $tabs,
'pagerContent' => false,
));
How do i add an 'id' and 'class' property to each of the tab 'item1' and 'preview'?
i tried:
'item1' => array(
'label' => 'label1',
'content' => $content1,
'id' => 'some id'
'class' => 'some class'
),
'preview' => array(
'label' => 'Preview',
'id' => 'some other id'
'class' => 'some other class'
),
But this doesn't add a class to it. I only see <li>'s
that serves as the container for the tabs. Sorry i'm a newbie here. I'd appreciate any help Thanks!
You should try this:
'item1' => array(
'label' => 'label1',
'content' => $content1,
'htmlOptions'=>array(
'id' => 'some id'
'class' => 'some class'
),
),
I haven't tried it but I'm following yii bootstrap logic here. Tell me if it's not working.

Magento - custom admin grid issue

I've been writing a custom out of stock module for the magento backend, I have mass actions, export etc working. However when i do any sort of search function (like put something in the product name field) and indeed try to change to the next page (or input a specific page into the field) or how many products appear on a page. It immediately redirects me to the dashboard.
Can anyone point me in the right direction as to where the code is that handles this function? I'm going to assume its part of the controller, but i've been searching for the last hour and is now time to ask for help!!
Thanks for any help you can provide!
Prepare columns function:
protected function _prepareColumns()
{
$this->addColumn('sku',
array(
'header'=> Mage::helper('catalog')->__('SKU'),
'width' => '80px',
'index' => 'sku',
));
$sets = Mage::getResourceModel('eav/entity_attribute_set_collection')
->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId())
->load()
->toOptionHash();
$this->addColumn('set_name',
array(
'header'=> Mage::helper('catalog')->__('Attrib. Set Name'),
'width' => '60px',
'index' => 'attribute_set_id',
'type' => 'options',
'options' => $sets,
));
$store = $this->_getStore();
if ($store->getId()) {
$this->addColumn('custom_name',
array(
'header'=> Mage::helper('catalog')->__('Name in %s', $store->getName()),
'index' => 'custom_name',
));
}
$this->addColumn('name',
array(
'header'=> Mage::helper('catalog')->__('Name'),
'index' => 'name',
));
$this->addColumn('stock_status',
array(
'header'=> 'Availability',
'width' => '60px',
'index' => 'stock_status',
'type' => 'options',
'options' => array('1'=>'In stock','0'=>'Out of stock'),
));
$this->addColumn('custom_stock_status',
array(
'header' => 'Custom Stock Status',
'width' => '60px',
'index' => 'custom_stock_status',
'type' => 'options',
'editable' => 'true',));
$this->addColumn('eol',
array(
'header'=> Mage::helper('catalog')->__('EoL'),
'width' => '20px',
'type' => 'checkbox',
'index' => 'eol',
'onclick' => 'this.value = this.checked ? 1 : 0;',
'values' => array('1','2'),
'editable' => 'true',
));
$store = $this->_getStore();
$this->addColumn('qty',
array(
'header'=> Mage::helper('catalog')->__('Qty'),
'width' => '25px',
'type' => 'number',
'index' => 'qty',
));
$this->addColumn('status',
array(
'header'=> Mage::helper('catalog')->__('Status'),
'width' => '70px',
'index' => 'status',
'type' => 'options',
'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(),
));
$this->addColumn('action',
array(
'header' => Mage::helper('catalog')->__('Action'),
'width' => '90px',
'type' => 'action',
'getter' => 'getId',
'actions' => array(
array(
'caption' => Mage::helper('catalog')->__('Edit Product'),
'url' => array(
'base'=>'store_admin/catalog_product/edit',
'params'=>array('store'=>$this->getRequest()->getParam('store'))
),
'field' => 'id'
)
),
'filter' => false,
'sortable' => false,
'index' => 'stores',
));
$this->addRssList('rss/catalog/notifystock', Mage::helper('catalog')->__('Notify Low Stock RSS'));
return parent::_prepareColumns();
}
Furthermore i'm trying to filter by an attribute, I need to filter the same attribute twice in order to output both null and no attributes, but not yes. Is there anyway to do this?
->addAttributeToFilter('eol', array('null' => true), 'left')
->addAttributeToFilter('eol', array('No' => true));
This is what i'm trying to do at the moment, however, it doesn't work in the slightest. Both work individually fine!
Mage_Adminhtml_Block_Widget_Grid
has a method
_addColumnFilterToCollection($column)
You can override it to implement filtering logic for your custom grid.
For CE 1.6.2, this worked for me:
1) Copy over app/code/core/Mage/Adminhtml/Block/Catalog/Product/Grid.php to app/code/local/Mage/Adminhtml/Block/Catalog/Product/Grid.php
2) add the code below from app/code/local/Mage/Adminhtml/Block/Catalog/Product/Grid.php inside/under _prepareCollection()
AFTER ->addAttributeToSelect('type_id'); and before if (Mage::helper('catalog')->isModuleEnabled('Mage_CatalogInventory')) {
CODE:
$collection->joinTable( 'cataloginventory/stock_item',
'product_id=entity_id', array("stock_status" => "is_in_stock") )
->addAttributeToSelect('stock_status');
3) Add the below around line 180 after
'index' => 'price', ));
CODE:
$this->addColumn('stock_status',
array(
'header'=> 'Stock Status', // this is the title of the column
'width' => '60px', // this is the width of the column
'index' => 'stock_status',
'type' => 'options',
'options' => array('1'=>'In Stock','0'=>'Out Of Stock'),
)
);

Categories