Magento:我需要从哪个catalog_product_flat中进行选择?什么是catalog_product_entity_datetime 表?

发布于 2024-09-27 17:13:18 字数 3787 浏览 2 评论 0原文

了解需要向哪些客户发送通知邮件以及了解哪些产品在优惠到期前 2 小时剩余, 我需要从需要与catelog_product_flat_X连接的wishlist、wishlist_item、customer_entity和catalog_product_enity表中进行选择 但是有很多catelog_product_flat_X表(X有1到64) 如何知道我需要加入哪个表?

这是catalog_product_flat表的结构,其中包含我需要的字段“special_to_date”和“visibility”

CREATE TABLE `catalog_product_flat_1` (
`entity_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`attribute_set_id` smallint(5) unsigned NOT NULL DEFAULT '0',
`type_id` varchar(32) NOT NULL DEFAULT 'simple',
`cost` decimal(12,4) DEFAULT NULL,
`created_at` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`enable_googlecheckout` tinyint(1) DEFAULT NULL,
`has_options` smallint(6) NOT NULL DEFAULT '0',
`image_label` varchar(255) DEFAULT NULL,
`links_exist` int(11) DEFAULT NULL,
`links_purchased_separately` int(11) DEFAULT NULL,
`links_title` varchar(255) DEFAULT NULL,
`name` varchar(255) DEFAULT NULL,
`news_from_date` datetime DEFAULT NULL,
`news_to_date` datetime DEFAULT NULL,
`price` decimal(12,4) DEFAULT NULL,
`price_type` int(11) DEFAULT NULL,
`price_view` int(11) DEFAULT NULL,
`required_options` tinyint(3) unsigned NOT NULL DEFAULT '0',
`shipment_type` int(11) DEFAULT NULL,
`short_description` text,
`sku` varchar(64) DEFAULT NULL,
`sku_type` int(11) DEFAULT NULL,
`small_image` varchar(255) DEFAULT NULL,
`small_image_label` varchar(255) DEFAULT NULL,
`special_from_date` datetime DEFAULT NULL,
`special_price` decimal(12,4) DEFAULT NULL,
`special_to_date` datetime DEFAULT NULL,
`tax_class_id` int(11) DEFAULT NULL,
`thumbnail` varchar(255) DEFAULT NULL,
`thumbnail_label` varchar(255) DEFAULT NULL,
`updated_at` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`url_key` varchar(255) DEFAULT NULL,
`url_path` varchar(255) DEFAULT NULL,
`visibility` tinyint(3) unsigned DEFAULT NULL,
`weight` decimal(12,4) DEFAULT NULL,
`weight_type` int(11) DEFAULT NULL,
PRIMARY KEY (`entity_id`),
KEY `IDX_TYPE_ID` (`type_id`),
KEY `IDX_ATRRIBUTE_SET` (`attribute_set_id`),
KEY `IDX_NAME` (`name`),
KEY `IDX_PRICE` (`price`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

这是catalog_product_entity,我可以知道产品的id(entity_id)

CREATE TABLE `catalog_product_entity` (
`entity_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`entity_type_id` smallint(8) unsigned NOT NULL DEFAULT '0',
`attribute_set_id` smallint(5) unsigned NOT NULL DEFAULT '0',
`type_id` varchar(32) NOT NULL DEFAULT 'simple',
`sku` varchar(64) DEFAULT NULL,
`has_options` smallint(1) NOT NULL DEFAULT '0',
`required_options` tinyint(1) unsigned NOT NULL DEFAULT '0',
`created_at` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`updated_at` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`entity_id`),
KEY `FK_CATALOG_PRODUCT_ENTITY_ENTITY_TYPE` (`entity_type_id`),
KEY `FK_CATALOG_PRODUCT_ENTITY_ATTRIBUTE_SET_ID` (`attribute_set_id`),
KEY `sku` (`sku`)
) ENGINE=InnoDB AUTO_INCREMENT=50 DEFAULT CHARSET=utf8 COMMENT='Product Entities';

以及catalog_product_entity_datetime表是什么?我看到它还在值字段中存储了与special_to_date 的值相同的值

CREATE TABLE `catalog_product_entity_datetime` (
`value_id` int(11) NOT NULL AUTO_INCREMENT,
`entity_type_id` smallint(5) unsigned NOT NULL DEFAULT '0',
`attribute_id` smallint(5) unsigned NOT NULL DEFAULT '0',
`store_id` smallint(5) unsigned NOT NULL DEFAULT '0',
`entity_id` int(10) unsigned NOT NULL DEFAULT '0',
`value` datetime DEFAULT NULL,
PRIMARY KEY (`value_id`),
UNIQUE KEY `IDX_ATTRIBUTE_VALUE` (`entity_id`,`attribute_id`,`store_id`),
KEY `FK_CATALOG_PRODUCT_ENTITY_DATETIME_ATTRIBUTE` (`attribute_id`),
KEY `FK_CATALOG_PRODUCT_ENTITY_DATETIME_STORE` (`store_id`),
KEY `FK_CATALOG_PRODUCT_ENTITY_DATETIME_PRODUCT_ENTITY` (`entity_id`)
) ENGINE=InnoDB AUTO_INCREMENT=11873 DEFAULT CHARSET=utf8;

请帮助我如何做到这一点。

提前致谢, 里西

To know who are the customers needed to be sent the notification mail and know which are the products remain 2 hours before the deal expired,
I need to select from wishlist, wishlist_item, customer_entity and catalog_product_enity table which need to join with catelog_product_flat_X
But there are many catelog_product_flat_X tables (X has from 1 to 64)
How to know which table I need to join with?

Here is the structure of the catalog_product_flat table which has fields "special_to_date" and "visibility" I need

CREATE TABLE `catalog_product_flat_1` (
`entity_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`attribute_set_id` smallint(5) unsigned NOT NULL DEFAULT '0',
`type_id` varchar(32) NOT NULL DEFAULT 'simple',
`cost` decimal(12,4) DEFAULT NULL,
`created_at` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`enable_googlecheckout` tinyint(1) DEFAULT NULL,
`has_options` smallint(6) NOT NULL DEFAULT '0',
`image_label` varchar(255) DEFAULT NULL,
`links_exist` int(11) DEFAULT NULL,
`links_purchased_separately` int(11) DEFAULT NULL,
`links_title` varchar(255) DEFAULT NULL,
`name` varchar(255) DEFAULT NULL,
`news_from_date` datetime DEFAULT NULL,
`news_to_date` datetime DEFAULT NULL,
`price` decimal(12,4) DEFAULT NULL,
`price_type` int(11) DEFAULT NULL,
`price_view` int(11) DEFAULT NULL,
`required_options` tinyint(3) unsigned NOT NULL DEFAULT '0',
`shipment_type` int(11) DEFAULT NULL,
`short_description` text,
`sku` varchar(64) DEFAULT NULL,
`sku_type` int(11) DEFAULT NULL,
`small_image` varchar(255) DEFAULT NULL,
`small_image_label` varchar(255) DEFAULT NULL,
`special_from_date` datetime DEFAULT NULL,
`special_price` decimal(12,4) DEFAULT NULL,
`special_to_date` datetime DEFAULT NULL,
`tax_class_id` int(11) DEFAULT NULL,
`thumbnail` varchar(255) DEFAULT NULL,
`thumbnail_label` varchar(255) DEFAULT NULL,
`updated_at` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`url_key` varchar(255) DEFAULT NULL,
`url_path` varchar(255) DEFAULT NULL,
`visibility` tinyint(3) unsigned DEFAULT NULL,
`weight` decimal(12,4) DEFAULT NULL,
`weight_type` int(11) DEFAULT NULL,
PRIMARY KEY (`entity_id`),
KEY `IDX_TYPE_ID` (`type_id`),
KEY `IDX_ATRRIBUTE_SET` (`attribute_set_id`),
KEY `IDX_NAME` (`name`),
KEY `IDX_PRICE` (`price`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Here is the catalog_product_entity which I can know the id of the product (entity_id)

CREATE TABLE `catalog_product_entity` (
`entity_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`entity_type_id` smallint(8) unsigned NOT NULL DEFAULT '0',
`attribute_set_id` smallint(5) unsigned NOT NULL DEFAULT '0',
`type_id` varchar(32) NOT NULL DEFAULT 'simple',
`sku` varchar(64) DEFAULT NULL,
`has_options` smallint(1) NOT NULL DEFAULT '0',
`required_options` tinyint(1) unsigned NOT NULL DEFAULT '0',
`created_at` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`updated_at` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`entity_id`),
KEY `FK_CATALOG_PRODUCT_ENTITY_ENTITY_TYPE` (`entity_type_id`),
KEY `FK_CATALOG_PRODUCT_ENTITY_ATTRIBUTE_SET_ID` (`attribute_set_id`),
KEY `sku` (`sku`)
) ENGINE=InnoDB AUTO_INCREMENT=50 DEFAULT CHARSET=utf8 COMMENT='Product Entities';

and what is catalog_product_entity_datetime table? I see it also store the same value to the special_to_date's value in the value field

CREATE TABLE `catalog_product_entity_datetime` (
`value_id` int(11) NOT NULL AUTO_INCREMENT,
`entity_type_id` smallint(5) unsigned NOT NULL DEFAULT '0',
`attribute_id` smallint(5) unsigned NOT NULL DEFAULT '0',
`store_id` smallint(5) unsigned NOT NULL DEFAULT '0',
`entity_id` int(10) unsigned NOT NULL DEFAULT '0',
`value` datetime DEFAULT NULL,
PRIMARY KEY (`value_id`),
UNIQUE KEY `IDX_ATTRIBUTE_VALUE` (`entity_id`,`attribute_id`,`store_id`),
KEY `FK_CATALOG_PRODUCT_ENTITY_DATETIME_ATTRIBUTE` (`attribute_id`),
KEY `FK_CATALOG_PRODUCT_ENTITY_DATETIME_STORE` (`store_id`),
KEY `FK_CATALOG_PRODUCT_ENTITY_DATETIME_PRODUCT_ENTITY` (`entity_id`)
) ENGINE=InnoDB AUTO_INCREMENT=11873 DEFAULT CHARSET=utf8;

Please help me how to do it.

Thanks in advanced,
Rithy

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

内心荒芜 2024-10-04 17:13:18

为此,您应该使用 magento 目录/产品方法,而不是原始 sql 查询。
因此从 Mage::getModel('catalog/product')->getCollection() 开始并添加连接,直到获得所需的数据; Catalog_flat 表和任何其他表仅供 magento 内部使用。
平面表是由magento出于EAV模式性能目的而创建的。

You should use magento catalog/product methods for this, not a raw sql query.
so start at the Mage::getModel('catalog/product')->getCollection() and add joins until you get the data you want; the catalog_flat tables and any other table are only meant to use internally by magento.
the flat tables are created by magento from the EAV schema performance purposes.

伴随着你 2024-10-04 17:13:18

Magento 的目录产品数据结构实现了实体-属性-值模型。您需要阅读 EAV(参考 Wikipedia),然后查阅 Magento < a href="http://www.magentocommerce.com/wiki/2_-_magento_concepts_and_architecture/magento_database_diagram#the_magento_eav_data_model" rel="nofollow">数据库图表。

Magento's catalog product data structure implements the Entity-Attribute-Value model. You need to read up on EAV (ref Wikipedia), then consult the Magento database diagrams.

无名指的心愿 2024-10-04 17:13:18

插话,这可能对其他人有帮助,所以我想写一些笔记。

我需要将猫#放入购物车中以触发布尔事件。恕我直言,平坦的桌子似乎不可靠。平底是为了表现而提供的,我不知道法师如何使用它们,而且一般也不关心。

加上数据库、模板和所有内容的每次更新都发生了巨大的根本性变化——这变得很可怕。

所以这里有两个问题需要考虑。

# get basic product ID from the sku (via something like this : $_item->getSku() ) - returns ID = 122 in my case
select entity_id from `magento_store`.`catalog_product_entity` where sku = 'THE_SKU';

## Use that value to tie to the cat index as such:
SELECT * FROM `magento_store`.`catalog_category_product_index` where product_id = 122; # returns 61 and 62 in my case, the matching cat id #s in the admin.

当然考虑加入。

因此,在此示例中,返回的 entity_id 是产品 ID,category_id 是猫的 ID。现在使用 1.4.1。

要非常小心,我在核心系统中发现了恶意错误。 Magento 是个糟糕的魔力。

因此,回到最初的问题 - 正是这样的查询,您可以开始将自己的信息连接在一起以满足平面/缓存下的特定需求。幸运的是,桌子上有一些标签可以提供帮助。这不是一件容易的事——也不是不可能。我建议尽可能使用 carious MVC/类似功能。

干杯!

更新:出现的平面表#是商店编号(废话)。它应该与 uri 中的 # 匹配,例如

index.php/admin/catalog_product/index/store/2/

将是 flat2 表。

Chiming in, this may help others so I wanted to put some notes up.

I need to pull cat #'s in the cart to fire off a bool event. The flat tables seem unreliable IMHO. Flats are presented for performance and I don't have a grasp on how Mage uses them, and don't care generally.

Compound that with the overwhelming radical changes each update on the DB, template, everything - it gets scary.

So here are 2 queries to think about.

# get basic product ID from the sku (via something like this : $_item->getSku() ) - returns ID = 122 in my case
select entity_id from `magento_store`.`catalog_product_entity` where sku = 'THE_SKU';

## Use that value to tie to the cat index as such:
SELECT * FROM `magento_store`.`catalog_category_product_index` where product_id = 122; # returns 61 and 62 in my case, the matching cat id #s in the admin.

Consider a join of course.

So in this example the entity_id returned is the product id and category_id is the cat #'s. Using 1.4.1 right now.

Be very careful I have found malicious errors in the core system. Magento is bad mojo.

So hitting on the original question - it is queries like this where you can start joining your own info together for specific needs under the flats/cache. Luckily the tables are kinda labeled to help. Not an easy task - not impossible either. I recommend using the carious MVC/similar functionality when ever you can.

Cheers!

Update: Appears the flat table # is the store number (duh). It should match the # in the uri such as

index.php/admin/catalog_product/index/store/2/

woudl be flat2 table.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文