OpenCart:如何准确填充oc_category_path [英] OpenCart: How to accurately populate oc_category_path

查看:141
本文介绍了OpenCart:如何准确填充oc_category_path的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用在线服务将数据从其他电子商务网站传输到 OpenCart ,并且一切似乎都已正确传输.

I have used an online service to transfer data from my other ecommerce website into OpenCart and everything seems to have been transferred correctly.

但是,产品类别存在一个问题.类别已转移到oc_category表中;但是,如果我希望能够在admin中编辑类别,则似乎还需要填充另一个名为oc_category_path的表.

There is however one issue with the product categories. The categories have been transferred to the oc_category table; however, looks like there is another table called oc_category_path that needs to be populated as well if I want to be able to edit my categories in the admin.

您知道此表是什么以及如何正确填充它(我想应该是手动的).确切地说,什么是path_idlevel?什么决定一个类别的级别?

Do you know what this table is and how I can correctly populate it (manually in my case I suppose). What is the path_id and level to be exact and what determines the level of a category?

相关表格:

CREATE TABLE `oc_category` (
  `category_id` int(11) NOT NULL AUTO_INCREMENT,
  `image` varchar(255) DEFAULT NULL,
  `parent_id` int(11) NOT NULL DEFAULT '0',
  `top` tinyint(1) NOT NULL,
  `column` int(3) NOT NULL,
  `sort_order` int(3) NOT NULL DEFAULT '0',
  `status` tinyint(1) NOT NULL,
  `date_added` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `date_modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`category_id`)
) ENGINE=MyISAM AUTO_INCREMENT=12 DEFAULT CHARSET=utf8

CREATE TABLE `oc_category_description` (
  `category_id` int(11) NOT NULL,
  `language_id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` text NOT NULL,
  `meta_description` varchar(255) NOT NULL,
  `meta_keyword` varchar(255) NOT NULL,
  `u_title` varchar(255) NOT NULL,
  `u_h1` varchar(255) NOT NULL,
  `u_h2` varchar(255) NOT NULL,
  PRIMARY KEY (`category_id`,`language_id`),
  KEY `name` (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8

CREATE TABLE `oc_category_path` (
  `category_id` int(11) NOT NULL,
  `path_id` int(11) NOT NULL,
  `level` int(11) NOT NULL,
  PRIMARY KEY (`category_id`,`path_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8

推荐答案

如果oc存储中的类别是根类别,则它将在路径表中获得一个条目,例如"category_id,category_id,0". 如果该类别有一个子类别,它将在表中获得两个条目,即:-"category_id,category_id,1"以及"category_id,parent_id,0".

If a category in your oc store is a root category, it gets an entry in the path table as such "category_id,category_id,0". if that category has a child it will get two entries in the table, namely :-"category_id,category_id,1" as well as "category_id,parent_id,0".

如果该孩子有一个自己的孩子,则该新孩子将具有以下三个条目:-
"category_id,category_id,2"
"category_id,parent_id,1"
"category_id,父母的父母category_id,0"

If that child has a it's own child, that new child will have three entries as such :-
"category_id,category_id,2"
"category_id,parent_id,1"
"category_id,parents parent category_id,0"

为了说明这一点,假设类别的category_id为"14". 它是category_id为"11"的类别的第一个子级. 类别ID为"11"的该类别是类别ID为"1"的类别中的子级. (1> 11> 14,显示在管理面板中,但名称而不是category_id除外)

To illustrate this, assume a category has a category_id of "14". It is the first child of a category with a category_id of "11". That category, with the category_id of "11" is the child on a category with the category id of "1". (1>11>14 as show in the admin panel, except with the name instead of the category_id)

上面将有3个条目,例如:
"14","14","2"
"14","11","1"
"14","1","0"

The above will have 3 entries as such :
"14","14","2"
"14","11","1"
"14","1","0"

因此,根目录的根类别将为0,下一个类别将为1,下一个为2,依此类推,所有这些都取决于其下层的类别级别.

So the root category to it will get 0, the next one gets 1, and the next 2, and so forth, all depending on how many category levels down it is.

我希望能对事情做充分的解释.

I hope that explain things well enough.

对于填充它,最简单的方法(但不是完整的方法)是仅使用"category_id,category_id,0"创建表.这将使它们显示在管理面板中.如果您随后单击修复",它将正确生成此表.

As for populating it, the simplest method, but not a complete method, is to just create the table with "category_id,category_id,0". This will get them to show up in the admin panel. If you then click on "repair" it will generate this table correctly.

或者,您将不得不遍历类别表,使用其parent_id创建一个数组,查找该parent_id作为其parent_id并将其添加到该数组中,依此类推.数组完成后,即不再有父级,将是一个简单的任务,将它们以正确的级别"添加到表中.

Alternatively you would have to step through you category table, creating an array with it's parent_id, looking up that parent_id for it's parent_id and adding it to the array, and so forth. When the array is complete, ie no more parents, it will be a simple task of adding them to the table with the correct "level".

仅供参考,还有一个表也需要填充,category_to_store,非常简单地是"category_id,store_id".没有此表,您将不会在商店中看到您的类别.

FYI, there is another table that needs populating as well, category_to_store, which is very simply "category_id,store_id". Without this table you will not see your categories in your store.

这篇关于OpenCart:如何准确填充oc_category_path的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆