integration issues – custom fields, speed, drop down list sort etc

  • wpsolr
    Keymaster
    2 years, 7 months ago #27797

    #1
    This code looks shallow. You can comment it I think. I’ll make more tests and remove it from core.

    Still wondering what the issue is with this code in your environment. Perhaps oldish PHP or WooCommerce (like the call to wc_clean)?

    Jmasked
    Participant
    2 years, 7 months ago #27801

    #1 and #3 are fixed now

    still need help with #2, #4
    lastly #5 I need to fix my code and know how to display these attributes within the single product “hit” template. I need the “brand” and the variation count displayed with the product.

    wpsolr
    Keymaster
    2 years, 7 months ago #27802

    #2
    WPSOLR facets widget should appear on your product category archive pages.
    Brands are not a standard archive.

    Jmasked
    Participant
    2 years, 7 months ago #27803

    #2 It’s working correctly, my apologies. It must have corrected itself after the new index

    wpsolr
    Keymaster
    2 years, 7 months ago #27804

    #4 Product variations
    Can you explain what you want to achieve?

    Jmasked
    Participant
    2 years, 7 months ago #27805

    So really what I need now is…

    I need to display certain attribute values on the single product item.
    For example “pwb-brand_str”: [
    “TOM FORD”
    ],
    how is this called?

    I also need to clean up my index
    the product thumbnail was never added to the index so the products don’t have images.
    No variation data linked to the parent product is in the index, no product image, no variation sku or attributes.
    The only thing close but not really is an empty value product attribute, this is what is in the index
    _product_attributes_s [
    {
    name:”pa_tom-ford_color”
    value:””
    position:”0″
    is_visible:”1″
    is_variation:”1″
    is_taxonomy:”1″
    }
    ]

    I also need this custom attribute added to the index to display the attribute count ie: “5 Colors”:

    function filter_custom_fields( array $custom_fields, WP_Post $post) {
        
        $product = wc_get_product( $post );
        // Extract prices.
        $variations_count = 0;
        if ( $product instanceof WC_Product_Variable ) {
            $variations_count = count( $product->get_available_variations() );
            $variations = $product->get_available_variations();
            $attricount      = count( $variations );
            $allattributes = $variations[0]['attributes'];
    }
    
         if($attricount > 0 && is_array($allattributes) && count( $allattributes ) == 1){
            foreach ($allattributes as $key => $value){
                $attriname = '';
                if(strpos($key, 'color')){
                    $attriname = 'Colors';
                }elseif(strpos($key, 'size')){
                    $attriname = 'Sizes';
                }else{
                    $rawattriname = substr($key, -5);
                    $attriname = ucwords(str_replace("_","",$key));
                }
                $variation_count_meta = $attricount . ' ' .$attriname;
                $custom_fields['variation_count_display'] = $variation_count_meta;
            }
        }
            return $custom_fields;
        
    }
    
    Jmasked
    Participant
    2 years, 7 months ago #27806

    I also have a bunch of date data in my index that I don’t think is necessary… This seems to be automatically generated

    wpsolr
    Keymaster
    2 years, 7 months ago #27807

    Elasticsearch is used only for searching, and displaying facets with our facets Widget.

    If you need to display other informations, just use standard WordPress/WooCommerce functions
    For instance:

    I need to display certain attribute values on the single product item.

    $product = wc_get_product();
    echo $product->get_attribute( ‘pwb-brand’ )

    I also have a bunch of date data in my index that I don’t think is necessary… This seems to be automatically generated

    This data is used by WPSOLR for efficiently filtering or sorting in different add-ons.

    Jmasked
    Participant
    2 years, 7 months ago #27808

    I am using Algolia, how do I include the attribute value in my hit template using your plugin?
    I am still missing product image, variation data, attribute values etc. Algolia controls the front end hits display… So I would need those values not only for hits display but for searching…

    I currently have the brand being generated by a function in product loops, it’s working on the homepage, however it’s broken on any pages like search or category that use algolia.

    I need the custom function field for attribute count to work.

    wpsolr
    Keymaster
    2 years, 7 months ago #27809

    What is a “hit template”?

    Jmasked
    Participant
    2 years, 7 months ago #27810

    in algolia the display of the results is controlled by a hit template, meaning the way the product itself displays.

    wpsolr
    Keymaster
    2 years, 7 months ago #27811

    Seeing #5, you already know how to add custom data to your index.
    If you build your own Algolia UI with your own Algolia query, you can retrieve and display this custom data as you wish.

    Jmasked
    Participant
    2 years, 7 months ago #27812

    my code to add the custom data isn’t working though.

    Also I was looking to use the plugins built in features and needed to know how to access the attribute values by html

    wpsolr
    Keymaster
    2 years, 7 months ago #27813

    I fear this is out of the support scope, as it is about custom php/js/html code.

    Jmasked
    Participant
    2 years, 7 months ago #27814

    how do I get the basics like product image to work?

Viewing 15 posts - 46 through 60 (of 63 total)

You must be logged in to reply to this topic.