This solution for OC 2.x


--- Example for Search page on Opencart default 2.2.x


Expectation:


1. Create a xml file to install via Extension Installer

Example: "customize-button-search-page.ocmod.xml" make sure the name will like "name.ocmod.xml" and the code "<code>....</code>" is the only one


2. Add short code into Controller file to generate design link

This step i will add it into "catalog\controller\product\search.php" at three positions 

Note: need find the keyword to search is the most suitable

 

<file path="catalog/controller/product/search.php">
		<operation>
			<search><![CDATA[$this->load->model('catalog/product');]]></search>
			<add position="after"><![CDATA[
				$this->load->language('fancy_design/productdesigner');
				$data['text_customized_product'] = $this->language->get('text_customized_product');
				$this->document->addStyle('catalog/view/javascript/fancy_design/css/fancy-product.css');
				$this->load->model('catalog/fnt_product_design');
			]]></add>
		</operation>
		<operation>
			<search><![CDATA[$data['products'][] = array(]]></search>
			<add position="before"><![CDATA[
				$product_design = $this->model_catalog_fnt_product_design->getProductDesignByProduct($result['product_id']);
                if($product_design){
                    $link_design = $this->url->link('product/fnt_product_design','product=' . $result['product_id']);
                } else {$link_design = NULL;}
			]]></add>
		</operation>
		<operation>
			<search><![CDATA[$data['products'][] = array(]]></search>
			<add position="after"><![CDATA[
				'link_design' => $link_design,
			]]></add>
		</operation>
	</file>

 

3. Add short code to place the button where need to place

This step i will add it into "catalog\view\theme\default\template\product\search.tpl" at one positions 

Note: need find the keyword to search is the most suitable


 

<file path="catalog/view/theme/*/template/product/search.tpl">
		<operation>
			<search><![CDATA[<div class="button-group">]]></search>
			<add position="before"><![CDATA[
				<?php if($product['link_design']){?>
					<div class="button-group"><button style="width:100%" class="btn-customize" onclick="window.location.href='<?php echo $product['link_design']; ?>'"><i class="fa fa-edit"></i> <?php echo $text_customized_product;?></button></div>
				<?php }?>
			]]></add>
		</operation>
	</file>

 

4. Install this file via Extension installer at admin panel. Don't forget clear and refresh to generate the new cache file


I attach a file below for example.