Created
May 1, 2019 08:41
-
-
Save nicomollet/0fdb6941ec17ded0b94d76ab7fc7b7f4 to your computer and use it in GitHub Desktop.
WooCommerce: Adds Brand attribute to "Product" Structured Data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* WooCommerce: Adds Brand attribute to "Product" Structured Data | |
* | |
* @param array $data | |
* | |
* @return array | |
*/ | |
function woocommerce_structured_data_product_brand ($data) { | |
global $product; | |
$data['brand'] = 'Custom Brand' ?? null; | |
return $data; | |
} | |
add_filter( 'woocommerce_structured_data_product', 'woocommerce_structured_data_product_brand' ); |
@stephdigiovanni faudrait savoir quelle donnée est récupérée par ce plugin, en toute logique ça devrait être Brand :(
J'ai recupéré leur modèle de données en CSV et c'est bien "brand" qui est attendu.
Après il y a peut-être un cache.
Ce filtre ne fait que modifier le schema (rich text) en ajoutant brand.
Si le plugin ne se base pas dessus, ça ne va pas marcher.
Faudrait vérifier comment sont transmis les produits à Facebook, tu sais ?
J'ai du cache (litespeed) sur le serveur mais je l'ai vidé.
Je pense que FB utilise un fichier au format JSON/LD
J'ai fait un echo $data['brand'] et ça renvoie bien la marque. Donc soit c'ets un pb de cache soit le filter marche pas. Non ?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
J'ai modifié ta ligne "$data['brand'] = 'Custom Brand' ?? null;" par "$data['brand'] = $product->get_attribute('pa_marque') ?? null;" et sur Facebook je n'ai toujours pas la marque des produits...