gpt4 book ai didi

sql - Magento:有没有办法将所有可配置产品设置为 "Not Visible Individually"

转载 作者:搜寻专家 更新时间:2023-10-30 22:00:02 26 4
gpt4 key购买 nike

我想将可配置产品的所有子项设置为“单独不可见”,并且还为可配置产品的子项激活网站下的复选框。

有办法吗?

最佳答案

如果您没有 MySQL 访问权限,我相信这也可以:

$sites=Mage::app()->getWebsites(true);
foreach($sites as $site){
$site_list[]=$site->getWebsiteId();
}

$products=Mage::getResourceModel("catalog/product_collection")->addAttributeToFilter("type_id","configurable");

foreach ($products as $product){
$child_products = $product->getTypeInstance()->getAssociatedProducts();

$child_product_ids=array();

foreach($child_products as $child_product){
array_push($child_product_ids,$child_product->getId());
}

Mage::getSingleton('catalog/product_action')->updateAttributes(
$child_product_ids,
array(
'visibility' => "1",
'website_ids' => $site_list
),
Mage::app()->getStore()->getId()
);

}

关于sql - Magento:有没有办法将所有可配置产品设置为 "Not Visible Individually",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19008102/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com