Question

I have a Magento with only one store view. However this store is not default one. The news store view was created (ID: 2) and the default one deleted.

Then I have products and images imported with some tool. In admin everything is sparky. The correct thumbnail, small image and base image are selected and image is not excluded. In the front end image shows up correctly at the products info page but is not showing up at products listing.

If I print out the product object at the category listing I can see that no images are even loaded. No properties at all. However image labels are loaded well.

Here is the example row of my catalog_product_entity_varchar:

value_id    entity_type_id  attribute_id    store_id    entity_id   value
--------------------------------------------------------------------------------------------
1004        4               86              2           101         /2/7/271074_2.jpg

Where 86 coresponds to small_image attribute.

And now the last thing. If I change the store ID to 0 image is shown correctly. I can easily set it to 0 for all products as long as I have only one store view, but shouldn't it also be shown with 2? Why with 2 it displays at products details page and not in the listing?

PS: Default store view, no extensions.

Was it helpful?

Solution

Do you have a default value for that element, or just the storeview specific value?

SELECT
  `t_d`.`entity_id`,
  `t_d`.`attribute_id`,
  `t_d`.`value` AS `default_value`,
  `t_s`.`value` AS `store_value`,
  IF(t_s.value_id IS NULL, t_d.value, t_s.value) AS `value`
FROM `catalog_product_entity_varchar` AS `t_d`
LEFT JOIN `catalog_product_entity_varchar` AS `t_s`
 ON t_s.attribute_id = t_d.attribute_id AND t_s.entity_id = t_d.entity_id AND t_s.store_id = 2
...

Here is a snippet from the queries that load attributes in product lists. As you can see, if you have no default value for that attribute, the first part will return no results, and the LEFT JOIN won't work correctly. This means that you always need the default value AND the storeview value; Magento will decide the correct value in the calculated field IF(...) as value.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top