<?xml version="1.0" encoding="UTF-8"?>
<modification>
        <name>DearSoft Add Caption to Cateogory and Product</name>
		<code>DearSoft_add_caption_category_product</code>
		<version>3.0</version>
		<author>DearSoft</author>
		<link>https://dearsoft.bd</link>
		
	<file path="admin/model/catalog/category.php">
		
		<!-- <operation>
			<search><![CDATA[name = '" . $this->db->escape($value['name']) . "',]]></search>
			<add position="replace">
			<![CDATA[
			name = '" . $this->db->escape($value['name']) . "', caption = '" . $this->db->escape($value['caption']) . "',
			]]>
			</add>
		</operation> -->

		<operation>
			<search><![CDATA[foreach ($data['category_description'] as $language_id => $value) {]]></search>
			<add position="after" offset="1">
			<![CDATA[
			if(isset($value['caption'])){
		        $this->db->query("UPDATE " . DB_PREFIX . "category_description SET caption = '" . $this->db->escape($value['caption']) . "' WHERE category_id = '" . (int)$category_id . "'");
		    }
			]]>
			</add>
		</operation>
		
		<operation>
			<search><![CDATA[$category_description_data[$result['language_id']] = array(]]></search>
			<add position="after">
			<![CDATA[
			'caption'          => $result['caption'],
			]]>
			</add>
		</operation>
	</file>

	<file path="admin/language/en-gb/catalog/category.php">
		<operation error="ignore">
			<search><![CDATA[// Error]]></search>
			<add position="before">
			<![CDATA[
	$_['entry_caption']		= 'Caption';
			]]>
			</add>
		</operation>
	</file> 

	<file path="admin/view/template/catalog/category_form.twig">
		<operation>
			<search><![CDATA[<label class="col-sm-2 control-label" for="input-description{{ language.language_id }}">{{ entry_description }}</label>]]></search>
			<add position="before" offset="1"><![CDATA[
			  <div class="form-group">
	                    <label class="col-sm-2 control-label" for="input-caption{{ language.language_id }}">{{ entry_caption }}</label>
	                    <div class="col-sm-10">
	                      <input type="text" name="category_description[{{ language.language_id }}][caption]" value="{{ category_description[language.language_id] ? category_description[language.language_id].caption }}" placeholder="{{ entry_caption }}" id="input-name{{ language.language_id }}" class="form-control" />
	                      {% if error_name[language.language_id] %}
	                      <div class="text-danger">{{ error_name[language.language_id] }}</div>
	                      {% endif %}
	                    </div>
	                  </div>
			]]></add>
		</operation>
		</file>

		<file path="admin/model/catalog/product.php">
			<!-- <operation>
				<search><![CDATA[name = '" . $this->db->escape($value['name']) . "',]]></search>
				<add position="replace">
				<![CDATA[
				name = '" . $this->db->escape($value['name']) . "', caption = '" . $this->db->escape($value['caption']) . "',
				]]>
				</add>
			</operation> -->

			<operation>
			<search><![CDATA[foreach ($data['product_description'] as $language_id => $value) {]]></search>
			<add position="after" offset="1">
			<![CDATA[
			if(isset($value['caption'])){
		        $this->db->query("UPDATE " . DB_PREFIX . "product_description SET caption = '" . $this->db->escape($value['caption']) . "' WHERE product_id = '" . (int)$product_id . "'");
		    }
			]]>
			</add>
		</operation>
			
			<operation>
				<search><![CDATA[$product_description_data[$result['language_id']] = array(]]></search>
				<add position="after">
				<![CDATA[
				'caption'             => $result['caption'],
				]]>
				</add>
			</operation>
		</file>

	<file path="admin/language/en-gb/catalog/product.php">
		<operation error="ignore">
			<search><![CDATA[// Error]]></search>
			<add position="before">
			<![CDATA[
	$_['entry_caption']		= 'Caption';
			]]>
			</add>
		</operation>
	</file> 

	<file path="admin/view/template/catalog/product_form.twig">
		<operation>
			<search><![CDATA[<label class="col-sm-2 control-label" for="input-description{{ language.language_id }}">{{ entry_description }}</label>]]></search>
			<add position="before" offset="1"><![CDATA[
			  <div class="form-group">
                      <label class="col-sm-2 control-label" for="input-caption{{ language.language_id }}">{{ entry_caption }}</label>
                      <div class="col-sm-10">
                        <input type="text" name="product_description[{{ language.language_id }}][caption]" value="{{ product_description[language.language_id] ? product_description[language.language_id].caption }}" placeholder="{{ entry_caption }}" id="input-name{{ language.language_id }}" class="form-control"/>
                      </div>
                    </div>
			]]></add>
		</operation>
		</file>

		<file path="catalog/controller/product/category.php">
		<operation>
			<search><![CDATA[$data['heading_title'] = $category_info['name'];]]></search>
			<add position="after"><![CDATA[
			  if(!empty($category_info['caption'])){
                $data['caption'] = $category_info['caption'];
            }else{
                $data['caption'] = '';
            }
			]]></add>
		</operation>
		</file>

		<file path="catalog/model/catalog/product.php">
		<operation>
			<search><![CDATA['name'             => $query->row['name'],]]></search>
			<add position="after"><![CDATA[
			  'caption'             => $query->row['caption'],
			]]></add>
		</operation>
		</file>

		<file path="catalog/controller/product/product.php">
		<operation>
			<search><![CDATA[$data['heading_title'] = $product_info['name'];]]></search>
			<add position="after"><![CDATA[
			  if(!empty($product_info['caption'])){
                $data['caption'] = $product_info['caption'];
            }else{
                $data['caption'] = '';
            }
			]]></add>
		</operation>
		</file>

</modification>