Cho em hỏi, khi em kiểm tra Thiếu trường Brand MPN trong sản phẩm Structured Data Schema Woocommerce khi kiểm tra ở trang search.google.com/structured-data/testing-tool/ làm sao để hết bị lỗi này trên wordpress vậy. Mình đang sử dụng mã nguần wordpress, themes falatsome.
Bạn add code sau vào nhé file function.php của themes nhé: PHP: //fix lỗi sản phẩm thiếu Brand, mpn, id có thể tùy biến thêmfunction itseovn_custom_woocommerce_structured_data_product ($data) { global $product; $data['brand'] = $data['brand'] = ['@type' => 'Brand', 'name' => $product->get_attribute('pa_manufacturer') ?? null]; $data['mpn'] = $product->get_sku() ? $product->get_sku() : null; $data['id'] = $product->get_id() ? $product->get_id() : null; return $data;}add_filter( 'woocommerce_structured_data_product', 'itseovn_custom_woocommerce_structured_data_product' ); Đổi ITSEOVN thành thương hiệu web bạn nhé. Nếu bạn có brand cố định thì tự gắn thẳng vào code lun như sau: PHP: //fix lỗi sản phẩm thiếu Brand, mpn, id có thể tùy biến thêmfunction itseovn_custom_woocommerce_structured_data_product ($data) { global $product; $data['brand'] = ['@type' => 'Brand', 'name' => 'ITSEOVN']; $data['mpn'] = $product->get_sku() ? $product->get_sku() : null; $data['id'] = $product->get_id() ? $product->get_id() : null; return $data;}add_filter( 'woocommerce_structured_data_product', 'itseovn_custom_woocommerce_structured_data_product' );