gpt4 book ai didi

mysql - 如何在 Woocommerce 中删除具有相同产品 ID 的重复产品?

转载 作者:行者123 更新时间:2023-12-03 23:42:44 33 4
gpt4 key购买 nike

我更新了数据库。更新后,我在 Woocommerce 中遇到了重复的产品——即使我在数据库中没有重复的产品。
我删除了 transient ,但它没有修复。如果您指导我如何修复它,我将不胜感激。
提前致谢。
Products
Database
下面的块显示了事件插件的列表


+------------------------------------------------+--------+------------------------------+----------+
| name | status | update | version |
+------------------------------------------------+--------+------------------------------+----------+
| wc-abandoned-carts-by-small-fish-analytics | active | none | 2.6.2 |
| admin-menu-search | active | none | 1.2 |
| woo-advanced-shipment-tracking | active | available | 3.1.4 |
| woo-auto-coupons | active | none | 1.3.2 |
| better-search-replace | active | none | 1.3.3 |
| bookly-responsive-appointment-booking-tool | active | none | 18.9 |
| bookly-addon-pro | active | none | 3.1 |
| code-snippets | active | none | 2.14.0 |
| commercegurus-commercekit | active | none | 1.1.7 |
| customizer-export-import | active | none | 0.9.2 |
| delete-duplicate-posts | active | none | 4.4.7 |
| elementor | active | none | 3.0.13 |
| elementor-pro | active | available | 3.0.5 |
| essential-addons-for-elementor-lite | active | none | 4.3.6 |
| essential-addons-elementor | active | available | 4.2.1 |
| export-import-menus | active | none | 1.6.0 |
| facebook-for-woocommerce | active | available | 1.9.11 |
| kliken-marketing-for-google | active | none | 1.0.6 |
| jet-engine | active | available | 2.5.2 |
| kirki | active | none | 3.1.5 |
| mailchimp-for-woocommerce | active | none | 2.4.7 |
| one-click-demo-import | active | none | 2.6.1 |
| payment-gateways-by-user-roles-for-woocommerce | active | none | 1.2.3 |
| seo-by-rank-math | active | available | 1.0.52.1 |
| redux-framework | active | available | 4.1.21 |
| google-site-kit | active | none | 1.20.0 |
| smart-variations-images-premium | active | none | 4.0.75 |
| string-locator | active | none | 2.4.1 |
| analogwp-templates | active | none | 1.7.5 |
| transients-manager | active | none | 1.8.1 |
| updraftplus | active | available | 1.16.29 |
| woo-variation-swatches | active | available | 1.1.0 |
| woocommerce | active | none | 4.7.0 |
| woocommerce-advanced-bulk-edit | active | none | 4.5 |
| advanced-product-labels-for-woocommerce | active | available | 1.1.16.4 |
| woocommerce-attribute-images | active | none | 1.2.0 |
| woocommerce-brands | active | none | 1.6.10 |
| woocommerce-composite-products2 | active | none | 7.1.1 |
| woocommerce-currency-converter-widget | active | none | 1.6.23 |
| woocommerce-email-test | active | version higher than expected | 2.1 |
| order-emails-log-for-woocommerce | active | version higher than expected | 2.0 |
| woocommerce-order-status-manager | active | none | 1.9.2 |
| woocommerce-product-bundles | active | none | 6.4.0 |
| woocommerce-sequential-order-numbers | active | none | 1.9.5 |
| woocommerce-gateway-stripe | active | none | 4.5.5 |
| weight-based-shipping-for-woocommerce | active | none | 5.3.7 |
| wordpress-importer | active | none | 0.7 |
| xforwoocommerce | active | none | 1.2.8 |
| yith-woocommerce-pre-order-premium | active | none | 1.5.9 |
+------------------------------------------------+--------+------------------------------+----------+
我还发现我在类别页面上有不同价格的重复产品,而在内页中有相同的价格!

最佳答案

事实上,我有两个问题。第一个问题是产品列表页面中的重复产品,我发现问题与以下代码有关:

add_filter('posts_clauses', 'order_by_stock_status');
function order_by_stock_status($posts_clauses) {
global $wpdb;
// only change query on WooCommerce loops
if ( is_woocommerce() && (is_shop() || is_product_category() || is_product_tag() || is_product_taxonomy())) {
$posts_clauses['join'] .= " INNER JOIN $wpdb->postmeta istockstatus ON ($wpdb->posts.ID = istockstatus.post_id) ";
$posts_clauses['orderby'] = " istockstatus.meta_value ASC, " . $posts_clauses['orderby'];
$posts_clauses['where'] = " AND istockstatus.meta_key = '_stock_status' AND istockstatus.meta_value <> '' " . $posts_clauses['where'];
}
return $posts_clauses;
}

我添加了 !is_admin()到条件,然后它固定。
我也有另一个同样的问题,但这次是在类别页面。对于这种情况,我检查了插件,我发现 xforwoocommerce(过滤器)插件以不同的价格制作了重复的产品! :| (不知道为什么!)
我禁用了它并修复了它,但我认为根本原因是上面的代码。
感谢@benjamin、@grégory-c 和@Mtxz!

关于mysql - 如何在 Woocommerce 中删除具有相同产品 ID 的重复产品?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64818535/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com