• Resolved Eugenijus

    (@ugenijus)


    Hello

    When I duplicated site (with woocommerce), product attributes doesn’t copied.
    What’s wrong with setup?
    Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi there,

    product attributes are custom WordPress taxonomies, and are thus stored in the core database tables for taxonomies and terms in the according site.

    Adding a new site to your network, based on an existing site (i.e., duplicating that site), should work fine with taxonomies. However, you have to make sure you also duplicate all custom WooCommerce tables. I explained how to do this for Revolution Slider over here. Just add in all WooCommerce tables.

    Do you have WooCommerce activated per site, or network wide? It has to be activated per site.

    Also, please refrain from cross posting topics on both our dedicated support forum on MultilingualPress.org and here. Thanks.

    Cheers,
    Thorsten

    Thread Starter Eugenijus

    (@ugenijus)

    Hello,

    I also found that other woocommerce data doesnt copied, and resolved with this:

    add_filter( 'mlp_tables_to_duplicate', function ( array $tables, array $context ) {
    
        $prefix = $GLOBALS['wpdb']->base_prefix . ( 1 == $context['source_blog_id'] ? '' : "{$context['source_blog_id']}_" );
    
        return array_merge( $tables, [
            "{$prefix}woocommerce_attribute_taxonomies",
            "{$prefix}woocommerce_order_items",
            "{$prefix}woocommerce_order_itemmeta",
            "{$prefix}woocommerce_tax_rates",
            "{$prefix}woocommerce_tax_rate_locations",
            "{$prefix}woocommerce_shipping_zones",
            "{$prefix}woocommerce_shipping_zone_locations",
            "{$prefix}woocommerce_shipping_zone_methods",
            "{$prefix}woocommerce_payment_tokens",
            "{$prefix}woocommerce_payment_tokenmeta",
            // ...
        ] );
    }, 10, 2 );

    I have main site tests.com and tests.com/en. The /en is duplicated from main site.
    Debug log, after I visit any product page on front end, show:

    [07-May-2017 07:02:13 UTC] WordPress database error Table ‘tests_wp4.wp_4_redirection_items’ doesn’t exist for query SELECT wp_4_redirection_items.*,wp_4_redirection_groups.position AS group_pos FROM wp_4_redirection_items INNER JOIN wp_4_redirection_groups ON wp_4_redirection_groups.id=wp_4_redirection_items.group_id AND wp_4_redirection_groups.status=’enabled’ AND wp_4_redirection_groups.module_id=1 WHERE (wp_4_redirection_items.regex=1 OR wp_4_redirection_items.url=’/en/checkout/?wc-ajax=update_order_review’) made by require(‘wp-blog-header.php’), require_once(‘wp-load.php’), require_once(‘wp-config.php’), require_once(‘wp-settings.php’), do_action(‘init’), WP_Hook->do_action, WP_Hook->apply_filters, WordPress_Module->init, Red_Item::get_for_url

    Hi,

    well it seems that redirection items table is not site-specific, but there is only a single one, tests_wp4.wp_redirection_items, for the whole network. This is just a wild guess, though, as I don’t have any idea where that table is coming from.

    Regarding network tables, you might have to differentiate between these and site-specific tables. For example like so:

    add_filter( 'mlp_tables_to_duplicate', function ( array $tables, array $context ) {
    
        // Network tables.
        $prefix = $GLOBALS['wpdb']->base_prefix;
    
        $tables = array_merge( $tables, [
            "{$prefix}redirection_items",
            // ...
        ] );
    
        // Site-specific tables.
        if ( 1 == $context['source_blog_id'] ) {
            $prefix .= "{$context['source_blog_id']}_";
        }
    
        $tables = array_merge( $tables, [
            "{$prefix}woocommerce_attribute_taxonomies",
            "{$prefix}woocommerce_order_items",
            "{$prefix}woocommerce_order_itemmeta",
            // ...
        ] );
    
        return $tables;
    }, 10, 2 );

    Hope that helps.

    Cheers,
    Thorsten

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘product attributes’ is closed to new replies.