Support » Plugin: Product Feed PRO for WooCommerce » Missing _gtin custom attribute

  • Resolved Pacotole

    (@pacotole)


    All custom attributes that starts with “_” are excluded from field mapping.

    I can’t assign my _gtin custom field to Google Shopping Attribute g:gtin.

    • This topic was modified 2 years, 7 months ago by Pacotole.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor evavangelooven

    (@evavangelooven)

    Hi Pacotole,

    Thanks for using our plugin and reaching out to us. You are right, a few releases back we removed all custom attributes that start with a _ from the drop-downs as a lot of plugin’s and theme’s add custom attributes that start with a _ but are not relevant for WooCommerce products. It got so bad that some of the drop-downs became too long for users to work with. Hence, that is why we removed them.

    Would it be an option for you to just rename your attribute to gtin, without the _ ?

    All the best,
    Eva

    Thread Starter Pacotole

    (@pacotole)

    I have been able to solve the problem by adding a filter to the query:

    
    function fix_custom_attributes_query($query) {
        global $wpdb;
    
        if (strpos($query, "meta.meta_key NOT LIKE '\_%' OR meta.meta_key LIKE '\_woosea%' OR meta.meta_key='_product_attributes'") !== false) {
            $query = "SELECT meta.meta_id, meta.meta_key as name, meta.meta_value as type ".
                "FROM " . $wpdb->prefix . "postmeta AS meta, " . $wpdb->prefix . "posts AS posts " .
                "WHERE meta.post_id = posts.id " .
                "AND posts.post_type LIKE '%product%' ".
                "AND meta.meta_key NOT LIKE 'pyre%' ".
                "AND meta.meta_key NOT LIKE 'sbg_%' ".
                "AND meta.meta_key NOT LIKE 'wccaf_%' ".
                "AND meta.meta_key NOT LIKE 'rp_%' ".
                "AND meta.meta_key NOT LIKE '_oembed%' " . // extra clean
                "AND meta.meta_key NOT LIKE '_elementor%' " . // extra clean
                //disable "AND (meta.meta_key NOT LIKE '\_%' OR meta.meta_key LIKE '\_woosea%' OR meta.meta_key='_product_attributes') ".
                "GROUP BY meta.meta_key ".
                "ORDER BY meta.meta_key ASC;";
        }
    
        return $query;
    }
    add_filter('query', 'fix_custom_attributes_query');
    

    It would be great if the plugin had a filter to modify the list of Custom Attributes.

    Thanks!

    Plugin Contributor evavangelooven

    (@evavangelooven)

    Great you were able to solve the issue at hand yourselves.

    We will put your feature request on out wish-list 🙂

    All the best,
    Eva

    Thread Starter Pacotole

    (@pacotole)

    You could add in the custom attributes query a condition to include _gtin field
    meta.meta_key NOT LIKE '\_%' OR meta.meta_key = '_gtin'
    It’s a very used and important field.

    Anyway, it would be best to have a filter to modify the sql query.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Missing _gtin custom attribute’ is closed to new replies.