cancel
Showing results for 
Search instead for 
Did you mean: 

How can I creat an URL Link to search for a particular attribute?

How can I creat an URL Link to search for a particular attribute?

Hi there,

 

I have added a product attribute to some of my products. Is there a way for me to create a search link specially for the attribute? Maybe something like /instantsearch/result/?name_of_attribute=xxxx ?

 

 

2 REPLIES 2

Re: How can I creat an URL Link to search for a particular attribute?

@MadisonCooper 

 

If you are looking that specific url then you has to do customisations but if you are looking products specific to that attribute only then you can enable for search this attribute from Magento admin.

https://amasty.com/knowledge-base/magento-2-search-settings-and-terms.html

https://www.mageplaza.com/kb/magento-2-weight-search.html

Manish Mittal
https://www.manishmittal.com/

Re: How can I creat an URL Link to search for a particular attribute?

@MadisonCooper 

 

If you are not looking to purchase any module, you can create your own:

 

Flow below steps

Step:1

Create file Ar_Custom.xml at location app\etc\modules and add below code

<?xml version="1.0"?>
<config>
    <modules>
        <Ar_Custom>
            <active>true</active>
            <codePool>community</codePool>
        </Ar_Custom>
    </modules>
</config>

Step:2 Create Observer.php at location app\code\community\Ar\Custom\Model\

<?php
class Ar_Custom_Model_Observer
{
    public function addMassAction($observer)
    {
        $block = $observer->getEvent()->getBlock();
        $this->_block = $block;
        if (get_class($block) == 'Mage_Adminhtml_Block_Widget_Grid_Massaction' && $block->getRequest()->getControllerName() == 'sales_order') {
            $block->addItem('custom_action', array(
                'label' => Mage::helper('sales')->__('Custom Action'),
                'url' => $block->getUrl('*/custom/masscustom'),
            ));
        }
    }
}

Step:3 Create CustomController.php file at location app\code\community\Ar\Custom\controllers\Adminhtml\CustomController.php and below code

<?php
class Ar_Custom_Adminhtml_CustomController extends Mage_Adminhtml_Controller_Action
{

    public function massCustomAction()
    {
        $orderIds = $this->getRequest()->getPost('order_ids', array());
        $this->_redirect('adminhtml/sales_order/');
    }
}

Step:4 Create config.xml file at location app\code\community\Ar\Custom\etc and add below code

<?xml version="1.0"?>
<config>
    <modules>
        <Ar_Custom>
            <version>1.0.1</version>
        </Ar_Custom>
    </modules>
    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <Ar_Custom after="Mage_Adminhtml">Ar_Custom_Adminhtml</Ar_Custom>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>
     <adminhtml>
        <events>
            <core_block_abstract_prepare_layout_before>
                <observers>
                    <newmodule_core_block_abstract_prepare_layout_before>
                        <type>model</type>
                        <class>Ar_Custom_Model_Observer</class>
                        <method>addMassAction</method>
                    </newmodule_core_block_abstract_prepare_layout_before>
                </observers>
            </core_block_abstract_prepare_layout_before>
        </events>
    </adminhtml>
    <global>
        <models>
            <custom>
                    <class>Ar_Custom_Model</class>
            </custom>
        </models>
        <resources>
            <custom_write>
                <connection>
                    <use>core_write</use>
                </connection>
            </custom_write>
            <custom_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </custom_read>
        </resources>
    </global>
</config>

Step:5 Flush and refresh all cache in admin end.

 

Add your logic for status update. Thanks

Manish Mittal
https://www.manishmittal.com/