注意:未定义的属性:Proxy :: checkFieldAtributeUnit opencart

时间:2018-03-29 21:16:26

标签: opencart

问题打开购物车2.3

扩展名:属性自定义多语言单元

启用时

  

注意:未定义的属性:第13行的vqcache \ vq2-admin_controller_catalog_attribute.php中的Proxy :: checkFieldAtributeUnit

$this->model_catalog_attribute->checkFieldAtributeUnit();

扩展

    <file name="admin/model/catalog/attribute.php">
            <!-- Check If column exists -->
            <operation>
                    <search position="after"><![CDATA[
                    class ModelCatalogAttribute extends Model {
                    ]]></search>
                    <add><![CDATA[
                    public function checkFieldAtributeUnit() {
                        $hasModelAtribute = FALSE;
                        $result = $this->db->query( "DESCRIBE `".DB_PREFIX."attribute_description`;" );
                            foreach ($result->rows as $row) {
                                if ($row['Field'] == 'unit') {
                                $hasModelAtribute = TRUE;
                                break;
                                }
                            }
                        if (!$hasModelAtribute) {
                         $sql = "ALTER TABLE `".DB_PREFIX."attribute_description` ADD `unit` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''";
                         $this->db->query( $sql );
                        }
                    }
                    ]]></add>
            </operation>
            <!-- Save value -->
            <operation>
                    <search position="before"><![CDATA[
                    $this->event->trigger('post.admin.attribute.edit', $attribute_id);
                    ]]></search>
                    <add><![CDATA[
                    foreach ($data['attribute_unit'] as $language_id => $value2) {
                        $this->db->query("UPDATE " . DB_PREFIX . "attribute_description SET unit = '" . $this->db->escape($value2['unit']) . "' WHERE attribute_id = '" . (int)$attribute_id . "' AND language_id = '" . (int)$language_id  . "'");
                    }
                    ]]></add>
            </operation>
            <operation>
                    <search position="after"><![CDATA[
                    'ad.name',
                    ]]></search>
                    <add><![CDATA[
                    'unit',
                    ]]></add>
            </operation>
            <!-- New function for units -->
            <operation> 
                    <search position="before"><![CDATA[
                    public function getAttributeDescriptions($attribute_id) {
                    ]]></search>
                    <add><![CDATA[
                    public function getAttributeUnits($attribute_id) {
                        $unit_data = array();
                        $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "attribute_description WHERE attribute_id = '" . (int)$attribute_id . "'");
                        foreach ($query->rows as $result) {
                            $unit_data[$result['language_id']] = array('unit' => $result['unit']);
                        }
                        return $unit_data;
                    }
                    ]]></add>
            </operation>
    </file> 

<file name="admin/controller/catalog/attribute.php">
            <!-- Check unit column -->
            <operation>
                    <search position="before" index="1"><![CDATA[
                    $this->getList();
                    ]]></search>
                    <add><![CDATA[
                    $this->model_catalog_attribute->checkFieldAtributeUnit();
                    ]]></add>
            </operation>
            <operation>
                    <search position="after"><![CDATA[
                    $data['attributes'][] = array(
                    ]]></search>
                    <add><![CDATA[
                    'unit'            => $result['unit'],
                    ]]></add>
            </operation>
            <operation>
                    <search position="before"><![CDATA[
                    $data['button_delete']
                    ]]></search>
                    <add><![CDATA[
                    $data['column_unit'] = $this->language->get('column_unit');
                    ]]></add>
            </operation>
            <operation>
                    <search position="before"><![CDATA[
                    $data['sort_name']
                    ]]></search>
                    <add><![CDATA[
                    $data['sort_unit'] = $this->url->link('catalog/attribute', 'token=' . $this->session->data['token'] . '&sort=unit' . $url, 'true');
                    ]]></add>
            </operation>
            <operation>
                    <search position="before"><![CDATA[
                    $data['button_save']
                    ]]></search>
                    <add><![CDATA[
                    $data['entry_unit'] = $this->language->get('entry_unit');
                    ]]></add>
            </operation>
            <operation>
                    <search position="before"><![CDATA[
                    if (isset($this->request->post['attribute_group_id'])) {
                    ]]></search>
                    <add><![CDATA[
                    if (isset($this->request->post['attribute_unit'])) {
                        $data['attribute_unit'] = $this->request->post['attribute_unit'];
                    } elseif (isset($this->request->get['attribute_id'])) {
                        $data['attribute_unit'] = $this->model_catalog_attribute->getAttributeUnits($this->request->get['attribute_id']);
                    } else {
                        $data['attribute_unit'] = array();
                    }
                    ]]></add>
            </operation>
    </file> 

您尝试了多个副本和相同的错误 任何帮助?

1 个答案:

答案 0 :(得分:1)

搜索未找到。 admin / model / catalog / attribute.php中的$this->event->trigger('post.admin.attribute.edit', $attribute_id);