BRD-1042-Emit-productType-as-separate-locale-aware-field#69
BRD-1042-Emit-productType-as-separate-locale-aware-field#69PauliusInvertus wants to merge 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request decouples Shopify's Standard Product Taxonomy from the legacy product type field, introducing a standalone productType attribute and removing the previous fallback logic for categoryDefault. Review feedback identifies this as a potential regression that could break search UI features like breadcrumbs and categorization. The reviewer recommends restoring the fallback for categoryDefault and ensuring that localized productType fields fall back to the primary locale's value when translations are unavailable.
| if ($categoryDefault !== '') { | ||
| $fields["categoryDefault_{$locale}"] = $categoryDefault; | ||
| } | ||
| $localeCategories = $this->buildCategories($categoryDefault, $this->extractTags($product)); | ||
| if (!empty($localeCategories)) { | ||
| $fields["categories_{$locale}"] = $localeCategories; | ||
| } | ||
|
|
||
| $localeProductType = $this->translated($localeTranslations, 'product_type') | ||
| ?? ($locale === $primaryLocale ? $nativeProductType : ''); | ||
| if ($localeProductType !== '') { | ||
| $fields["productType_{$locale}"] = $localeProductType; | ||
| } |
There was a problem hiding this comment.
The removal of the fallback to productType for categoryDefault and categories introduces a regression for products without a Shopify Standard Taxonomy assigned. In such cases, these fields will now be empty, which can break categorization and breadcrumbs in the search UI. Additionally, the productType field should fall back to the primary locale's value when a translation is missing, ensuring consistency with the name and description fields and preventing facets from disappearing in non-primary locales.
$localeProductType = $this->translated($localeTranslations, 'product_type') ?? $nativeProductType;
if ($localeProductType !== '') {
$fields["productType_{$locale}"] = $localeProductType;
}
$localeCategoryDefault = $categoryDefault !== '' ? $categoryDefault : $localeProductType;
if ($localeCategoryDefault !== '') {
$fields["categoryDefault_{$locale}"] = $localeCategoryDefault;
}
$localeCategories = $this->buildCategories($localeCategoryDefault, $this->extractTags($product));
if (!empty($localeCategories)) {
$fields["categories_{$locale}"] = $localeCategories;
}| 'categoryDefault' => $categoryDefault, | ||
| 'categories' => $this->buildCategories($categoryDefault, $this->extractTags($product)), | ||
| 'productType' => $nativeProductType !== '' ? $nativeProductType : null, |
There was a problem hiding this comment.
Similar to the localized fields, the plain categoryDefault and categories fields should maintain a fallback to productType when the Shopify Standard Taxonomy is missing to avoid empty categorization data for products relying on the legacy product type field.
'categoryDefault' => $categoryDefault !== '' ? $categoryDefault : $nativeProductType,
'categories' => $this->buildCategories($categoryDefault !== '' ? $categoryDefault : $nativeProductType, $this->extractTags($product)),
'productType' => $nativeProductType !== '' ? $nativeProductType : null,
Stops folding productType into categoryDefault as a fallback — emits it as its own productType_ field with proper per-locale translation lookup. Fixes the case where Shopify Standard Taxonomy (English-only) was masking a translated productType value, leaving non-English storefronts with English category labels.
BRD-1042