Reputation: 549
I want to add a small snipet of script above a block of script and another one under the same block in the same file. (I can't do a replace because the block is also modified by another extension).
If I had the same file twice I get the message "Modification requires a unique ID code" when installing the extension (Please note that if I remove one of the file section it uploads fine so the issue is not actually with the code ID) Here is what I have:
<?xml version="1.0" encoding="UTF-8"?>
<modification>
<name>Spare Parts</name>
<version>1.0</version>
<author>Olivier</author>
<code>spare_parts</code>
<link></link>
<file path="admin/model/catalog/product.php">
<operation error="log">
<search index="0"><![CDATA[$this->db->query("DELETE FROM " . DB_PREFIX . "product_option WHERE product_id = '" . (int)$product_id . "'");]]></search>
<add position="before"><![CDATA[
//spare parts extension
if ( $product_id !=671 )
{//only update the options if this product is not the spare parts
]]>
</add>
</operation>
</file>
<file path="admin/model/catalog/product.php">
<operation error="log">
<search index="1"><![CDATA[$this->db->query("DELETE FROM " . DB_PREFIX . "product_discount WHERE product_id = '" . (int)$product_id . "'");]></search>
<add position="before"><![CDATA[
}//end except spare parts
]]>
</add>
</operation>
</file>
</modification>
I have tried with using the twice in the same and even use the search and add twice under the one operation but I am getting the same error:
<?xml version="1.0" encoding="UTF-8"?>
<modification>
<name>Spare Parts</name>
<version>1.0</version>
<author>Olivier</author>
<code>spare_parts</code>
<link></link>
<file path="admin/model/catalog/product.php">
<operation error="log">
<search index="0"><![CDATA[$this->db->query("DELETE FROM " . DB_PREFIX . "product_option WHERE product_id = '" . (int)$product_id . "'");]]></search>
<add position="before"><![CDATA[
//spare parts extension
if ( $product_id !=671 )
{//only update the options if this product is not the spare parts
]]>
</add>
</operation>
<operation error="log">
<search index="1"><![CDATA[$this->db->query("DELETE FROM " . DB_PREFIX . "product_discount WHERE product_id = '" . (int)$product_id . "'");]></search>
<add position="before"><![CDATA[
}//end except spare parts
]]>
</add>
</operation>
</file>
</modification>
Upvotes: 0
Views: 188
Reputation: 1430
<?xml version="1.0" encoding="UTF-8"?>
<modification>
<name>Spare Parts</name>
<version>1.0</version>
<author>Olivier</author>
<code>spare_parts</code>
<link></link>
<file path="admin/model/catalog/product.php">
<operation error="log">
<search index="0"><![CDATA[$this->db->query("DELETE FROM " . DB_PREFIX . "product_option WHERE product_id = '" . (int)$product_id . "'");]]></search>
<add position="before"><![CDATA[
//spare parts extension
if ( $product_id !=671 )
{//only update the options if this product is not the spare parts
]]>
</add>
</operation>
<operation error="log">
<search index="0"><![CDATA[$this->db->query("DELETE FROM " . DB_PREFIX . "product_discount WHERE product_id = '" . (int)$product_id . "'");]></search>
<add position="before"><![CDATA[
}//end except spare parts
]]>
</add>
</operation>
</file>
</modification>
I have changed index="1"
to index="0"
When you use for the second add index="1"
you close your condition in the next function (public function copyProduct($product_id) {
). I assume you need this exception just for public function editProduct($product_id, $data) {
If you need it for the second function you must your conditions add separately.
Upvotes: 0