如何在Opencart版本2.3.0.2中将XML文件写入Cache?

时间:2017-06-30 07:33:35

标签: php xml opencart

我有包含Opencart中所有产品的xml文件,看起来像这样(它不是完整的文件)。

<?xml version="1.0" encoding="UTF-8"?>
<shop>
    <date_created>2017-06-29 13:58:36</date_created>
    <shopproduct>
        <product_id>47</product_id>
        <name>HP LP3065</name>
        <description>&amp;lt;p&amp;gt;&#13;
            Stop your co-workers in their tracks with the stunning new 30-inch diagonal HP LP3065 Flat Panel Monitor. This flagship monitor features best-in-class performance and presentation features on a huge wide-aspect screen while letting you work as comfortably as possible - you might even forget you&amp;amp;#39;re at the office&amp;lt;/p&amp;gt;&#13;
        </description>
        <model>Product 21</model>
        <sku/>
        <upc/>
        <ean/>
        <jan/>
        <manufacturer_id>7</manufacturer_id>
        <price>100.0000</price>
        <tax_class_id>9</tax_class_id>
        <points>400</points>
        <quantity>1000</quantity>
        <minimum>1</minimum>
        <isbn/>
        <mpn/>
        <meta_title>HP LP3065</meta_title>
        <stock_status_id>5</stock_status_id>
        <weight>1.00000000</weight>
        <weight_class_id>1</weight_class_id>
        <length>0.00000000</length>
        <length_class_id>1</length_class_id>
        <width>0.00000000</width>
        <height>0.00000000</height>
        <location/>
        <shipping>1</shipping>
        <meta_description/>
        <meta_keyword/>
        <viewed>0</viewed>
        <date_available>2009-02-03</date_available>
        <date_added>2009-02-03 21:08:40</date_added>
        <date_modified>2011-09-30 01:05:28</date_modified>
        <sort_order>0</sort_order>
        <status>1</status>
        <subtract>0</subtract>
    </shopproduct>
    <shopproduct>
        <product_id>28</product_id>
        <name>HTC Touch HD</name>
        <description>&amp;lt;p&amp;gt;&#13;

我想在System/Storage/Cache的缓存中写一下。我想它有现成的功能,但我不知道在哪里寻找它们。

1 个答案:

答案 0 :(得分:1)

您有DIR_CACHE定义的常量,因此只需将其与file_put_contents一起使用,并使用一个不会被重复使用的名称(以避免破坏您的数据)。