如何解决如何在 OCMOD 文件中为 opencart 2.3
我想在同一文件中的一个脚本块上方添加一小段脚本,并在同一块下添加另一个脚本。 (我无法进行替换,因为该块也被另一个扩展修改了)。
如果我有两次相同的文件,我会在安装扩展程序时收到消息“修改需要唯一的 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>
解决方法
<?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>
我已将 index="1"
更改为 index="0"
当您使用第二个 add index="1"
时,您将在下一个函数 (public function copyProduct($product_id) {
) 中关闭您的条件。我假设您只需要 public function editProduct($product_id,$data) {
的这个例外如果您需要它的第二个功能,您必须单独添加您的条件。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。