• Resolved yahavcaine

    (@yahavcaine)


    I have created a custom shop/search page using crocoblock plugin listing grid. The issue is that now the ymm plugin search does not populate the search results into this product listing gird.

    Anyone has an idea how to make these two work?

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Pektsekye

    (@pektsekye)

    Hello,

    There is no solution for Jet Plugins from Crocoblock.

    I have a modification to make it filter products that were displayed with a shortcode:

    [products]

    So you can make a custom page with Elementor and then display products with the shortcode.

    And then to modify this plugin to make it use that custom page as the results page and to make it filter the products listed with the products shortcode.

    Contact me by email pektsekye@gmail.com if you need to get the modified files.

    Stanislav

    @pektsekye, if the search results can return a comma separated list of IDs, that can solve the issue. A person can easily use that shortcode with the Query Builder of JetEngine and have the listing grid function exactly as described.

    Thread Starter yahavcaine

    (@yahavcaine)

    I managed to get it to work with the listing grid with short function that modifies the WP query.

    For whoever is interested:

    1. Modify the query when the URL includes ymm_search=1
    2. Check if query is for products -> gets matching product id’s.
    3. Replaces the result to only include these product IDs.
    add_action('pre_get_posts', 'custom_ymm_query_modification', 9999);
    function custom_ymm_query_modification($query) {
        if (is_admin() || empty($_GET['ymm_search']) || '1' !== $_GET['ymm_search']) {
            return;
        }
    
        $post_type = $query->get('post_type');
        if ((is_array($post_type) && !in_array('product', $post_type, true)) || 'product' !== $post_type) {
            return;
        }
    
        if (class_exists('Pektsekye_Ymm_Controller_Product')) {
            $controller = new Pektsekye_Ymm_Controller_Product();
            if (method_exists($controller, 'getFoundProductIds')) {
                $found_ids = $controller->getFoundProductIds();
                if (is_array($found_ids) && !empty($found_ids)) {
                    $query->set('post__in', $found_ids);
                    $query->set('orderby', 'post__in');
                } else {
                    $query->set('post__in', array(0));
                }
                $query->set('s', false);
            }
        }
    }

    • This reply was modified 1 month, 1 week ago by yahavcaine.
Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.