Magento目录搜索查询约束错误 [英] Magento Catalog Search Query Constraint Error

查看:65
本文介绍了Magento目录搜索查询约束错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注意:这是 Magento目录搜索的后续操作查询说明

此查询:

INSERT INTO `catalogsearch_result` 
(
    SELECT 
        '0', 
        `s`.`product_id`, 
        -(
            ( MATCH(`s`.`data_index`) AGAINST ('ip335') ) + 
            ( 5 * ( MATCH(`s`.`data_index_1`) AGAINST('ip335') ) ) + 
            ( 3 * ( MATCH(`s`.`data_index_2`) AGAINST('ip335') ) ) + 
            ( 2 * ( MATCH(`s`.`data_index_3`) AGAINST ('ip335') ) ) 
        ) 

    FROM `mikkelrickycatalogsearch_fulltext` AS `s` 

    INNER JOIN `catalog_product_entity` AS `e`
        ON `e`.`entity_id`=`s`.`product_id` 

    WHERE 
        (
            (`s`.`data_index` LIKE '%ip335%')
        ) 
        AND `s`.`store_id`='2'
) 
ON DUPLICATE 
    KEY UPDATE `relevance` = VALUES(`relevance`);

我收到以下错误:

ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails 
(`magento_1_4`.`catalogsearch_result`, CONSTRAINT `FK_CATALOGSEARCH_RESULT_QUERY` FOREIGN KEY 
(`query_id`) REFERENCES `catalogsearch_query` (`query_id`) ON DELETE CASCADE ON UPDATE CASCADE)

问题是:为什么? :)

Question is: why? :)

在这种情况下,如果我只是将子查询作为SELECT语句运行,则会得到多个结果(因此可以找到给定条件的产品).但是,在catalogsearch_result上没有任何匹配产品的条目,这将导致上述查询执行INSERT.鉴于此,为什么它会引发约束错误? catalogsearch_query首先需要包含具有匹配的query_id记录的行吗?

In this case, if I just run the sub-query as a SELECT statement, I get several results back (so products are found for the given criteria). However, there are no entries on catalogsearch_result for any of the matching products, which would cause the above query to perform an INSERT. Given that, why does it throw the constraint error? Does catalogsearch_query first need to contain a row with a matching query_id record?

推荐答案

首先,您需要插入到catalogsearch_query,然后在其他表中插入.您可以检查例如

First you need to insert to catalogsearch_query and next in other tables. You can check this for example

这篇关于Magento目录搜索查询约束错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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