Tell us what you are trying to do?
WooCommerce added the option to choose brands for products, creating a brand taxonomy. I'm trying to use the Toolset Views block to display products from a category and order them by brand, but I don't know how to do it.
Is there any documentation that you are following?
I searched the documentation by I don't found the solution.
If yes, can you please share details on what page exactly you want to display it and under what section and share admin access details or for what brands you want to group products.
If no: can you plesae clarify your exact requirement.
Please share admin access details and problem URL.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
I have two primary product categories, each containing various brands. My goal is to arrange the products within each category by brand, ensuring that all products from a single brand appear consecutively in the display grid.
Currently, I'm using a Toolset View block to showcase products: one block for each main category. The challenge I'm facing is how to configure the internal sorting within these views to order by brand, rather than the default sorting by title or date.
As a temporary workaround, I've manually set the order and used the 'menu order' option, but this is proving to be cumbersome. I'm looking for a more efficient solution to automatically sort products by brand.
I will require problem URL and admin access details. Once I review your current strucure then I will be able to guide you in the right direction.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
The only option is, you should create a custom field that should hold the same term name (brand name) of "product_brand" taxonomy you assign to your post and then use this custom field to order by your posts.
Before performing any steps:
*** Please make a FULL BACKUP of your database and website.***
Here is a custom function that should help you to update the existing posts.
You can add the following code to "Custom Code" section offered by Toolset or try to add it to your current active theme's functions.php file.
function update_toolset_marca_producto_field() {
$args = array(
'post_type' => 'product', // Change this to your actual post type
'posts_per_page' => -1,
'post_status' => 'publish',
);
$posts = get_posts($args);
foreach ($posts as $post) {
$post_id = $post->ID;
// Get the assigned product_brand terms
$terms = wp_get_post_terms($post_id, 'product_brand');
if (!is_wp_error($terms) && !empty($terms)) {
// If multiple terms, you could concatenate or just use the first one
$brand_name = $terms[0]->name;
// Toolset custom field uses 'wpcf-' prefix
update_post_meta($post_id, 'wpcf-marca_producto', $brand_name);
}
}
}
add_action('init', 'update_toolset_marca_producto_field');
To avoid running this code on every page load:
Either wrap it in a condition like this:
if (is_admin() && isset($_GET['run_toolset_brand_sync'])) {
update_toolset_marca_producto_field();
}
Then trigger/run the above code only once by visiting:
<em><u>hidden link</u></em>
Once you see the existing posts are get updated and it has correct brand name filled with the custom field "marca_producto", you can set your view to order by custom field "marca_producto".