You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am importing a list of products from a json feed into Craft Commerce as Products. Some Products are created as enabled and some created as disabled.
In the Control Panel, I have verified that the value for enabled is coming in as expected.
Scout begins indexing only the enabled products correctly. But after the 20th product in the json feed, all subsequent products are indexed whether their status is enabled or disabled.
I have confirmed by passing "enabled" and "status" attributes into the Algolia index that the products are indeed disabled when they were indexed.
To resolve this temporarily I am including this code at the top of my transformer function.
publicstaticfunction transform(Entry|Product|Asset$element)
{
if (!$element->enabled) {
return [];
// ...
However, it feels like there is a bug here, and I'd like to understand the underlying issue rather than leave a check in the transformer.
Here is some debugging info. I'd be glad to provide more if it's helpful.
PHP 8.3.11
Craft Craft Pro 4.12.3
Commerce 4.6.12
Scout 4.1.1
This is a multisite install with separate indexes for English and Spanish products.
In my import Queue job, I call saveElement on the Product and then afterward on the default variant.
// ....if (!Craft::$app->elements->saveElement($product, true, true, true, true)) {
if ($product->hasErrors()) {
Craft::error('Errors: ' . print_r($product->getErrors(), true), __METHOD__);
}
thrownewException('Could not save product "' . $product->title . '". Please check the log folder for errors.');
}
$variant = $product->defaultVariant;
if (!$variant) {
thrownewException("No default variant found for '{$product->title}'");
}
$variant->title = $this->cleanTitle($this->part['PartName']);
$variant->sku = $newSku;
$variant->price = $newPrice;
$variant->hasUnlimitedStock = false;
$variant->stock = $newStock;
$variant->length = $newLength;
$variant->width = $newWidth;
$variant->height = $newHeight;
$variant->weight = $newWeight;
if (!Craft::$app->elements->saveElement($variant, true, true, true)) {
if ($variant->hasErrors()) {
Craft::error('Errors: ' . print_r($product->getErrors(), true), __METHOD__);
}
thrownewException("Could not save the default variant of '{$product->title}'");
}
// end of import queue job for product
Do you have any insight as to why some disabled products skip being indexed while later disabled products get indexed? Thanks for reading this through!
The text was updated successfully, but these errors were encountered:
I am importing a list of products from a json feed into Craft Commerce as Products. Some Products are created as enabled and some created as disabled.
In the Control Panel, I have verified that the value for enabled is coming in as expected.
Scout begins indexing only the enabled products correctly. But after the 20th product in the json feed, all subsequent products are indexed whether their status is enabled or disabled.
I have confirmed by passing "enabled" and "status" attributes into the Algolia index that the products are indeed disabled when they were indexed.
To resolve this temporarily I am including this code at the top of my transformer function.
However, it feels like there is a bug here, and I'd like to understand the underlying issue rather than leave a check in the transformer.
Here is some debugging info. I'd be glad to provide more if it's helpful.
This is a multisite install with separate indexes for English and Spanish products.
The Scout config criteria looks like this:
In my import Queue job, I call saveElement on the Product and then afterward on the default variant.
Do you have any insight as to why some disabled products skip being indexed while later disabled products get indexed? Thanks for reading this through!
The text was updated successfully, but these errors were encountered: