我想在一个脚本块上方添加一小段脚本,在同一文件的同一块下添加另一个脚本。(我无法进行替换,因为该块也被另一个扩展修改)。
如果我有两次相同的文件,我会在安装扩展程序时收到消息“修改需要唯一的 ID 代码”(请注意,如果我删除其中一个文件部分,它会正常上传,因此问题实际上与代码 ID 无关)在这里是我所拥有的:
<?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>
我曾尝试在同一操作中使用两次,甚至使用搜索并在一次操作下添加两次,但我得到了同样的错误:
<?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>