i create a product with Customizable Options but sometimes at frontend, the place which custom options should have appeared is now nothing enter image description here
I'm not sure why it happen, but when i resaving the product seems to solve that. Any idea what's the cause? How to prevent that? How to fix that for all products without resaving them all?
-
You can refer this issue in Github: github.com/magento/magento2/issues/10469Kirti Nariya– Kirti Nariya2019年03月14日 08:23:13 +00:00Commented Mar 14, 2019 at 8:23
-
hi @KirtiNariya i see this, but It has not been resolved yet in your linkInit– Init2019年03月14日 08:28:53 +00:00Commented Mar 14, 2019 at 8:28
3 Answers 3
After create or update product attribute programmatically (like tier price , etc..) by mistake product has_option set with false value.
check in "catalog_product_entity" table.
select entity_id, has_options, sku from `catalog_product_entity` where sku = {sky of yourproduct}
So update it if has_options value is zero or null.
UPDATE `catalog_product_entity` set has_options =1 where sku = {sky of yourproduct}
As describe @Gulshan. find out and update product which has_options column value are false.
SELECT * FROM `catalog_product_entity` WHERE entity_id in (SELECT product_id FROM `catalog_product_option`) and has_options = 0;
And update it with update query. Before update keep backup for table "catalog_product_entity" table.
UPDATE `catalog_product_entity` set has_options =1 where entity_id in (SELECT product_id FROM `catalog_product_option`) and has_options = 0 ;
Refresh cache and check product detail page.
-
1Thanks sumit, I have got same issue after migrate my site.S.P– S.P2019年12月11日 10:36:40 +00:00Commented Dec 11, 2019 at 10:36
I also faced the issue.
After doing some investigation I found that has_options column has 0 but product have at least one option associated in the product options table.
I didn't find a scenario to reproduce but it seems the product options were imported by any third party extension or migrated from an older version of Magento.
Re-saving product resolves the issue because there is a check at before product save that updates has_options value to 1.
So, I prepared below query to find all such products and managed to save all the resulted products.
SELECT * FROM `catalog_product_entity` WHERE entity_id in (SELECT product_id FROM `catalog_product_option`) and has_options = 0
I hope this may help someone facing the same issue.
its because of $product->save()
when you save product with orm, its setting has_options to 0. Shortly its a magento bug. To fix that issue in db level, you can execute the query below.
update catalog_product_entity t1
inner join catalog_product_option t2 on t2.product_id = t1.entity_id
set t1.has_options = 1
where t1.has_options = 0 and t1.type_id = 'simple';
update catalog_product_entity t1
inner join catalog_product_option t2 on t2.product_id = t1.entity_id and t2.is_require = 1
set t1.required_options = 1
where t1.required_options = 0
and t1.type_id = 'simple';
Explore related questions
See similar questions with these tags.