Set all child products to not visible individuallySet all associated product not visible individuallyQuery if a product is set to be visible on the websiteFilter Category Collection by Enabled, Visible ProductsMagmi import configurables don't associate simplesBest way to export and import productsSave all products through php/shell scriptMagento - Associated products are not showing under configurable productHow to diagnose “Invalid block type ” error?Magento simple products not visible individually still show upMagento 2.1.12 - all products not showing up categories and search results frontend

Has the laser at Magurele, Romania reached a tenth of the Sun's power?

What is the tangent at a sharp point on a curve?

What is this high flying aircraft over Pennsylvania?

Derivative of an interpolated function

Is there a distance limit for minecart tracks?

How can I, as DM, avoid the Conga Line of Death occurring when implementing some form of flanking rule?

Travelling in US for more than 90 days

I keep switching characters, how do I stop?

Output visual diagram of picture

C++ lambda syntax

Mortal danger in mid-grade literature

Magnifying glass in hyperbolic space

Why does the frost depth increase when the surface temperature warms up?

What should be the ideal length of sentences in a blog post for ease of reading?

Rendered textures different to 3D View

How do I prevent inappropriate ads from appearing in my game?

Sort with assumptions

If the Dominion rule using their Jem'Hadar troops, why is their life expectancy so low?

How to get directions in deep space?

Why does a 97 / 92 key piano exist by Bosendorfer?

A seasonal riddle

Pre-Employment Background Check With Consent For Future Checks

Friend wants my recommendation but I don't want to give it to him

Can you describe someone as luxurious? As in someone who likes luxurious things?



Set all child products to not visible individually


Set all associated product not visible individuallyQuery if a product is set to be visible on the websiteFilter Category Collection by Enabled, Visible ProductsMagmi import configurables don't associate simplesBest way to export and import productsSave all products through php/shell scriptMagento - Associated products are not showing under configurable productHow to diagnose “Invalid block type ” error?Magento simple products not visible individually still show upMagento 2.1.12 - all products not showing up categories and search results frontend













1















How to set all associated products in the entire store to 'not visible individually' I've been scrolling through other answers but I can't seem to find a solution.










share|improve this question
























  • You'd need to write a little script that loops through all configurable products, finds their children, loops through each child, sets the visibility, then saves each child. Let me know if you need some example code.

    – BlueC
    Sep 11 '16 at 7:40















1















How to set all associated products in the entire store to 'not visible individually' I've been scrolling through other answers but I can't seem to find a solution.










share|improve this question
























  • You'd need to write a little script that loops through all configurable products, finds their children, loops through each child, sets the visibility, then saves each child. Let me know if you need some example code.

    – BlueC
    Sep 11 '16 at 7:40













1












1








1








How to set all associated products in the entire store to 'not visible individually' I've been scrolling through other answers but I can't seem to find a solution.










share|improve this question
















How to set all associated products in the entire store to 'not visible individually' I've been scrolling through other answers but I can't seem to find a solution.







magento-1.9 product php






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 20 mins ago









Teja Bhagavan Kollepara

3,00641949




3,00641949










asked Sep 11 '16 at 7:29









PragmanPragman

10217




10217












  • You'd need to write a little script that loops through all configurable products, finds their children, loops through each child, sets the visibility, then saves each child. Let me know if you need some example code.

    – BlueC
    Sep 11 '16 at 7:40

















  • You'd need to write a little script that loops through all configurable products, finds their children, loops through each child, sets the visibility, then saves each child. Let me know if you need some example code.

    – BlueC
    Sep 11 '16 at 7:40
















You'd need to write a little script that loops through all configurable products, finds their children, loops through each child, sets the visibility, then saves each child. Let me know if you need some example code.

– BlueC
Sep 11 '16 at 7:40





You'd need to write a little script that loops through all configurable products, finds their children, loops through each child, sets the visibility, then saves each child. Let me know if you need some example code.

– BlueC
Sep 11 '16 at 7:40










1 Answer
1






active

oldest

votes


















2














Here is an example script that sets the children of both grouped and configurable products to Not Visible Individually.



Save this in ./shell/makechildrennotvisible.php and run from shell.



<?php
include_once '../app/Mage.php';
Mage::app()->setCurrentStore( Mage_Core_Model_App::ADMIN_STORE_ID );

// Get all configurable and grouped products
$products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('name')
->addAttributeToFilter('type_id', array('in' => array('configurable', 'grouped')));

// Loop each configurable product
foreach ($products as $_product)
// Get the child products for this product
if ($_product->getTypeId() == 'configurable')
$simpleProducts = $_product->getTypeInstance(true)->getUsedProductIds($_product);
elseif ($_product->getTypeId() == 'grouped')
$simpleProducts = $_product->getTypeInstance(true)->getAssociatedProductIds($_product);

printf("Setting children of Product ID %srn", $_product->getId());
// Loop each child product
foreach($simpleProducts as $_simpleID)
try
// Set associated product as not visible
$_simple = Mage::getModel('catalog/product')->load($_simpleID);
$_simple->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE);
$_simple->save();
printf("Product ID %s saved as 'Not Visible Individually'rn", $_simple->getId());
catch ( Exception $e )
print_r($e);





EDIT (browser version to process 10 products at a time)



Run this script in the browser as shell/makechildrennotvisible.php?page=1 and increment the page value each time until all products have been procesed. E.g.



www.example.com/shell/makechildrennotvisible.php?page=1

www.example.com/shell/makechildrennotvisible.php?page=2

www.example.com/shell/makechildrennotvisible.php?page=3



<?php
include_once '../app/Mage.php';
Mage::app()->setCurrentStore( Mage_Core_Model_App::ADMIN_STORE_ID );

// Get the current page from $_GET
$curPage = intval(Mage::app()->getRequest()->getParam('page'));
$curPage = $curPage < 1 ? 1 : $curPage;

// Get all configurable and grouped products
$products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('name')
->addAttributeToFilter('type_id', array('in' => array('configurable', 'grouped')))
->setPageSize(10);

$curPage = $curPage > $products->getLastPageNumber() ? $products->getLastPageNumber() : $curPage;
$products->setCurPage($curPage);

printf("Processing page %s of %s<br/>", $curPage, $products->getLastPageNumber());

// Loop each configurable product
foreach ($products as $_product)
// Get the child products for this product
if ($_product->getTypeId() == 'configurable')
$simpleProducts = $_product->getTypeInstance(true)->getUsedProductIds($_product);
elseif ($_product->getTypeId() == 'grouped')
$simpleProducts = $_product->getTypeInstance(true)->getAssociatedProductIds($_product);

printf("Setting children of Product ID %s<br/>", $_product->getId());
// Loop each child product
foreach($simpleProducts as $_simpleID)
try
// Set associated product as not visible
$_simple = Mage::getModel('catalog/product')->load($_simpleID);
$_simple->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE);
$_simple->save();
printf("Product ID %s saved as 'Not Visible Individually'<br/>", $_simple->getId());
catch ( Exception $e )
print_r($e);








share|improve this answer

























  • I have updated this answer to work with both grouped and configurable products and also to ensure the CurrentStore is set appropriately. Please let me know if it works and accept the answer if it does.

    – BlueC
    Sep 12 '16 at 15:00











  • Hi @bluec I haven't had a chance to run this yet but I have a few questions. Do I need to replace ADMIN_STORE_ID with the appropriate store I'd? Can you run this so it changes all stores products not just the selected store? Also I don't have shell access could I run this through the browser?

    – Pragman
    Sep 12 '16 at 18:08











  • @ZUBU You can leave Mage_Core_Model_App::ADMIN_STORE_ID exactly as it is since without this the product changes won't save. It will already change the visibility of all products from all stores. However, if you have product visibility set differently for different store scopes and wish to override this too then this would need some changes. You could run it in the browser but I don't recommend it. To do so you'd need to move it out of ./shell/ into the root directory and then change include_once '../app/Mage.php'; to include_once 'app/Mage.php';

    – BlueC
    Sep 12 '16 at 19:56











  • I was somewhat successful with the script but the script seemed to stop and not loop through the entire catalog??? Also when I re ran the script it had the exact same output as before i.e. changing the visibility of products it had already changed. I tried clearing cache and reindexing to no avail. So after trying multiple clearing cache etc after running the script for the tenth time it still returns the same as the first time running it. I am running the script through the browser. Any ideas?

    – Pragman
    Sep 13 '16 at 7:51






  • 1





    Ok just tried clearing the storage cahce and rerunning and it got about twice as far. Leads me to believe it might be a memory or time out issue???

    – Pragman
    Sep 13 '16 at 7:54










Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f135763%2fset-all-child-products-to-not-visible-individually%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














Here is an example script that sets the children of both grouped and configurable products to Not Visible Individually.



Save this in ./shell/makechildrennotvisible.php and run from shell.



<?php
include_once '../app/Mage.php';
Mage::app()->setCurrentStore( Mage_Core_Model_App::ADMIN_STORE_ID );

// Get all configurable and grouped products
$products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('name')
->addAttributeToFilter('type_id', array('in' => array('configurable', 'grouped')));

// Loop each configurable product
foreach ($products as $_product)
// Get the child products for this product
if ($_product->getTypeId() == 'configurable')
$simpleProducts = $_product->getTypeInstance(true)->getUsedProductIds($_product);
elseif ($_product->getTypeId() == 'grouped')
$simpleProducts = $_product->getTypeInstance(true)->getAssociatedProductIds($_product);

printf("Setting children of Product ID %srn", $_product->getId());
// Loop each child product
foreach($simpleProducts as $_simpleID)
try
// Set associated product as not visible
$_simple = Mage::getModel('catalog/product')->load($_simpleID);
$_simple->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE);
$_simple->save();
printf("Product ID %s saved as 'Not Visible Individually'rn", $_simple->getId());
catch ( Exception $e )
print_r($e);





EDIT (browser version to process 10 products at a time)



Run this script in the browser as shell/makechildrennotvisible.php?page=1 and increment the page value each time until all products have been procesed. E.g.



www.example.com/shell/makechildrennotvisible.php?page=1

www.example.com/shell/makechildrennotvisible.php?page=2

www.example.com/shell/makechildrennotvisible.php?page=3



<?php
include_once '../app/Mage.php';
Mage::app()->setCurrentStore( Mage_Core_Model_App::ADMIN_STORE_ID );

// Get the current page from $_GET
$curPage = intval(Mage::app()->getRequest()->getParam('page'));
$curPage = $curPage < 1 ? 1 : $curPage;

// Get all configurable and grouped products
$products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('name')
->addAttributeToFilter('type_id', array('in' => array('configurable', 'grouped')))
->setPageSize(10);

$curPage = $curPage > $products->getLastPageNumber() ? $products->getLastPageNumber() : $curPage;
$products->setCurPage($curPage);

printf("Processing page %s of %s<br/>", $curPage, $products->getLastPageNumber());

// Loop each configurable product
foreach ($products as $_product)
// Get the child products for this product
if ($_product->getTypeId() == 'configurable')
$simpleProducts = $_product->getTypeInstance(true)->getUsedProductIds($_product);
elseif ($_product->getTypeId() == 'grouped')
$simpleProducts = $_product->getTypeInstance(true)->getAssociatedProductIds($_product);

printf("Setting children of Product ID %s<br/>", $_product->getId());
// Loop each child product
foreach($simpleProducts as $_simpleID)
try
// Set associated product as not visible
$_simple = Mage::getModel('catalog/product')->load($_simpleID);
$_simple->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE);
$_simple->save();
printf("Product ID %s saved as 'Not Visible Individually'<br/>", $_simple->getId());
catch ( Exception $e )
print_r($e);








share|improve this answer

























  • I have updated this answer to work with both grouped and configurable products and also to ensure the CurrentStore is set appropriately. Please let me know if it works and accept the answer if it does.

    – BlueC
    Sep 12 '16 at 15:00











  • Hi @bluec I haven't had a chance to run this yet but I have a few questions. Do I need to replace ADMIN_STORE_ID with the appropriate store I'd? Can you run this so it changes all stores products not just the selected store? Also I don't have shell access could I run this through the browser?

    – Pragman
    Sep 12 '16 at 18:08











  • @ZUBU You can leave Mage_Core_Model_App::ADMIN_STORE_ID exactly as it is since without this the product changes won't save. It will already change the visibility of all products from all stores. However, if you have product visibility set differently for different store scopes and wish to override this too then this would need some changes. You could run it in the browser but I don't recommend it. To do so you'd need to move it out of ./shell/ into the root directory and then change include_once '../app/Mage.php'; to include_once 'app/Mage.php';

    – BlueC
    Sep 12 '16 at 19:56











  • I was somewhat successful with the script but the script seemed to stop and not loop through the entire catalog??? Also when I re ran the script it had the exact same output as before i.e. changing the visibility of products it had already changed. I tried clearing cache and reindexing to no avail. So after trying multiple clearing cache etc after running the script for the tenth time it still returns the same as the first time running it. I am running the script through the browser. Any ideas?

    – Pragman
    Sep 13 '16 at 7:51






  • 1





    Ok just tried clearing the storage cahce and rerunning and it got about twice as far. Leads me to believe it might be a memory or time out issue???

    – Pragman
    Sep 13 '16 at 7:54















2














Here is an example script that sets the children of both grouped and configurable products to Not Visible Individually.



Save this in ./shell/makechildrennotvisible.php and run from shell.



<?php
include_once '../app/Mage.php';
Mage::app()->setCurrentStore( Mage_Core_Model_App::ADMIN_STORE_ID );

// Get all configurable and grouped products
$products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('name')
->addAttributeToFilter('type_id', array('in' => array('configurable', 'grouped')));

// Loop each configurable product
foreach ($products as $_product)
// Get the child products for this product
if ($_product->getTypeId() == 'configurable')
$simpleProducts = $_product->getTypeInstance(true)->getUsedProductIds($_product);
elseif ($_product->getTypeId() == 'grouped')
$simpleProducts = $_product->getTypeInstance(true)->getAssociatedProductIds($_product);

printf("Setting children of Product ID %srn", $_product->getId());
// Loop each child product
foreach($simpleProducts as $_simpleID)
try
// Set associated product as not visible
$_simple = Mage::getModel('catalog/product')->load($_simpleID);
$_simple->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE);
$_simple->save();
printf("Product ID %s saved as 'Not Visible Individually'rn", $_simple->getId());
catch ( Exception $e )
print_r($e);





EDIT (browser version to process 10 products at a time)



Run this script in the browser as shell/makechildrennotvisible.php?page=1 and increment the page value each time until all products have been procesed. E.g.



www.example.com/shell/makechildrennotvisible.php?page=1

www.example.com/shell/makechildrennotvisible.php?page=2

www.example.com/shell/makechildrennotvisible.php?page=3



<?php
include_once '../app/Mage.php';
Mage::app()->setCurrentStore( Mage_Core_Model_App::ADMIN_STORE_ID );

// Get the current page from $_GET
$curPage = intval(Mage::app()->getRequest()->getParam('page'));
$curPage = $curPage < 1 ? 1 : $curPage;

// Get all configurable and grouped products
$products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('name')
->addAttributeToFilter('type_id', array('in' => array('configurable', 'grouped')))
->setPageSize(10);

$curPage = $curPage > $products->getLastPageNumber() ? $products->getLastPageNumber() : $curPage;
$products->setCurPage($curPage);

printf("Processing page %s of %s<br/>", $curPage, $products->getLastPageNumber());

// Loop each configurable product
foreach ($products as $_product)
// Get the child products for this product
if ($_product->getTypeId() == 'configurable')
$simpleProducts = $_product->getTypeInstance(true)->getUsedProductIds($_product);
elseif ($_product->getTypeId() == 'grouped')
$simpleProducts = $_product->getTypeInstance(true)->getAssociatedProductIds($_product);

printf("Setting children of Product ID %s<br/>", $_product->getId());
// Loop each child product
foreach($simpleProducts as $_simpleID)
try
// Set associated product as not visible
$_simple = Mage::getModel('catalog/product')->load($_simpleID);
$_simple->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE);
$_simple->save();
printf("Product ID %s saved as 'Not Visible Individually'<br/>", $_simple->getId());
catch ( Exception $e )
print_r($e);








share|improve this answer

























  • I have updated this answer to work with both grouped and configurable products and also to ensure the CurrentStore is set appropriately. Please let me know if it works and accept the answer if it does.

    – BlueC
    Sep 12 '16 at 15:00











  • Hi @bluec I haven't had a chance to run this yet but I have a few questions. Do I need to replace ADMIN_STORE_ID with the appropriate store I'd? Can you run this so it changes all stores products not just the selected store? Also I don't have shell access could I run this through the browser?

    – Pragman
    Sep 12 '16 at 18:08











  • @ZUBU You can leave Mage_Core_Model_App::ADMIN_STORE_ID exactly as it is since without this the product changes won't save. It will already change the visibility of all products from all stores. However, if you have product visibility set differently for different store scopes and wish to override this too then this would need some changes. You could run it in the browser but I don't recommend it. To do so you'd need to move it out of ./shell/ into the root directory and then change include_once '../app/Mage.php'; to include_once 'app/Mage.php';

    – BlueC
    Sep 12 '16 at 19:56











  • I was somewhat successful with the script but the script seemed to stop and not loop through the entire catalog??? Also when I re ran the script it had the exact same output as before i.e. changing the visibility of products it had already changed. I tried clearing cache and reindexing to no avail. So after trying multiple clearing cache etc after running the script for the tenth time it still returns the same as the first time running it. I am running the script through the browser. Any ideas?

    – Pragman
    Sep 13 '16 at 7:51






  • 1





    Ok just tried clearing the storage cahce and rerunning and it got about twice as far. Leads me to believe it might be a memory or time out issue???

    – Pragman
    Sep 13 '16 at 7:54













2












2








2







Here is an example script that sets the children of both grouped and configurable products to Not Visible Individually.



Save this in ./shell/makechildrennotvisible.php and run from shell.



<?php
include_once '../app/Mage.php';
Mage::app()->setCurrentStore( Mage_Core_Model_App::ADMIN_STORE_ID );

// Get all configurable and grouped products
$products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('name')
->addAttributeToFilter('type_id', array('in' => array('configurable', 'grouped')));

// Loop each configurable product
foreach ($products as $_product)
// Get the child products for this product
if ($_product->getTypeId() == 'configurable')
$simpleProducts = $_product->getTypeInstance(true)->getUsedProductIds($_product);
elseif ($_product->getTypeId() == 'grouped')
$simpleProducts = $_product->getTypeInstance(true)->getAssociatedProductIds($_product);

printf("Setting children of Product ID %srn", $_product->getId());
// Loop each child product
foreach($simpleProducts as $_simpleID)
try
// Set associated product as not visible
$_simple = Mage::getModel('catalog/product')->load($_simpleID);
$_simple->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE);
$_simple->save();
printf("Product ID %s saved as 'Not Visible Individually'rn", $_simple->getId());
catch ( Exception $e )
print_r($e);





EDIT (browser version to process 10 products at a time)



Run this script in the browser as shell/makechildrennotvisible.php?page=1 and increment the page value each time until all products have been procesed. E.g.



www.example.com/shell/makechildrennotvisible.php?page=1

www.example.com/shell/makechildrennotvisible.php?page=2

www.example.com/shell/makechildrennotvisible.php?page=3



<?php
include_once '../app/Mage.php';
Mage::app()->setCurrentStore( Mage_Core_Model_App::ADMIN_STORE_ID );

// Get the current page from $_GET
$curPage = intval(Mage::app()->getRequest()->getParam('page'));
$curPage = $curPage < 1 ? 1 : $curPage;

// Get all configurable and grouped products
$products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('name')
->addAttributeToFilter('type_id', array('in' => array('configurable', 'grouped')))
->setPageSize(10);

$curPage = $curPage > $products->getLastPageNumber() ? $products->getLastPageNumber() : $curPage;
$products->setCurPage($curPage);

printf("Processing page %s of %s<br/>", $curPage, $products->getLastPageNumber());

// Loop each configurable product
foreach ($products as $_product)
// Get the child products for this product
if ($_product->getTypeId() == 'configurable')
$simpleProducts = $_product->getTypeInstance(true)->getUsedProductIds($_product);
elseif ($_product->getTypeId() == 'grouped')
$simpleProducts = $_product->getTypeInstance(true)->getAssociatedProductIds($_product);

printf("Setting children of Product ID %s<br/>", $_product->getId());
// Loop each child product
foreach($simpleProducts as $_simpleID)
try
// Set associated product as not visible
$_simple = Mage::getModel('catalog/product')->load($_simpleID);
$_simple->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE);
$_simple->save();
printf("Product ID %s saved as 'Not Visible Individually'<br/>", $_simple->getId());
catch ( Exception $e )
print_r($e);








share|improve this answer















Here is an example script that sets the children of both grouped and configurable products to Not Visible Individually.



Save this in ./shell/makechildrennotvisible.php and run from shell.



<?php
include_once '../app/Mage.php';
Mage::app()->setCurrentStore( Mage_Core_Model_App::ADMIN_STORE_ID );

// Get all configurable and grouped products
$products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('name')
->addAttributeToFilter('type_id', array('in' => array('configurable', 'grouped')));

// Loop each configurable product
foreach ($products as $_product)
// Get the child products for this product
if ($_product->getTypeId() == 'configurable')
$simpleProducts = $_product->getTypeInstance(true)->getUsedProductIds($_product);
elseif ($_product->getTypeId() == 'grouped')
$simpleProducts = $_product->getTypeInstance(true)->getAssociatedProductIds($_product);

printf("Setting children of Product ID %srn", $_product->getId());
// Loop each child product
foreach($simpleProducts as $_simpleID)
try
// Set associated product as not visible
$_simple = Mage::getModel('catalog/product')->load($_simpleID);
$_simple->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE);
$_simple->save();
printf("Product ID %s saved as 'Not Visible Individually'rn", $_simple->getId());
catch ( Exception $e )
print_r($e);





EDIT (browser version to process 10 products at a time)



Run this script in the browser as shell/makechildrennotvisible.php?page=1 and increment the page value each time until all products have been procesed. E.g.



www.example.com/shell/makechildrennotvisible.php?page=1

www.example.com/shell/makechildrennotvisible.php?page=2

www.example.com/shell/makechildrennotvisible.php?page=3



<?php
include_once '../app/Mage.php';
Mage::app()->setCurrentStore( Mage_Core_Model_App::ADMIN_STORE_ID );

// Get the current page from $_GET
$curPage = intval(Mage::app()->getRequest()->getParam('page'));
$curPage = $curPage < 1 ? 1 : $curPage;

// Get all configurable and grouped products
$products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('name')
->addAttributeToFilter('type_id', array('in' => array('configurable', 'grouped')))
->setPageSize(10);

$curPage = $curPage > $products->getLastPageNumber() ? $products->getLastPageNumber() : $curPage;
$products->setCurPage($curPage);

printf("Processing page %s of %s<br/>", $curPage, $products->getLastPageNumber());

// Loop each configurable product
foreach ($products as $_product)
// Get the child products for this product
if ($_product->getTypeId() == 'configurable')
$simpleProducts = $_product->getTypeInstance(true)->getUsedProductIds($_product);
elseif ($_product->getTypeId() == 'grouped')
$simpleProducts = $_product->getTypeInstance(true)->getAssociatedProductIds($_product);

printf("Setting children of Product ID %s<br/>", $_product->getId());
// Loop each child product
foreach($simpleProducts as $_simpleID)
try
// Set associated product as not visible
$_simple = Mage::getModel('catalog/product')->load($_simpleID);
$_simple->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE);
$_simple->save();
printf("Product ID %s saved as 'Not Visible Individually'<br/>", $_simple->getId());
catch ( Exception $e )
print_r($e);









share|improve this answer














share|improve this answer



share|improve this answer








edited Sep 13 '16 at 8:44

























answered Sep 11 '16 at 7:56









BlueCBlueC

536415




536415












  • I have updated this answer to work with both grouped and configurable products and also to ensure the CurrentStore is set appropriately. Please let me know if it works and accept the answer if it does.

    – BlueC
    Sep 12 '16 at 15:00











  • Hi @bluec I haven't had a chance to run this yet but I have a few questions. Do I need to replace ADMIN_STORE_ID with the appropriate store I'd? Can you run this so it changes all stores products not just the selected store? Also I don't have shell access could I run this through the browser?

    – Pragman
    Sep 12 '16 at 18:08











  • @ZUBU You can leave Mage_Core_Model_App::ADMIN_STORE_ID exactly as it is since without this the product changes won't save. It will already change the visibility of all products from all stores. However, if you have product visibility set differently for different store scopes and wish to override this too then this would need some changes. You could run it in the browser but I don't recommend it. To do so you'd need to move it out of ./shell/ into the root directory and then change include_once '../app/Mage.php'; to include_once 'app/Mage.php';

    – BlueC
    Sep 12 '16 at 19:56











  • I was somewhat successful with the script but the script seemed to stop and not loop through the entire catalog??? Also when I re ran the script it had the exact same output as before i.e. changing the visibility of products it had already changed. I tried clearing cache and reindexing to no avail. So after trying multiple clearing cache etc after running the script for the tenth time it still returns the same as the first time running it. I am running the script through the browser. Any ideas?

    – Pragman
    Sep 13 '16 at 7:51






  • 1





    Ok just tried clearing the storage cahce and rerunning and it got about twice as far. Leads me to believe it might be a memory or time out issue???

    – Pragman
    Sep 13 '16 at 7:54

















  • I have updated this answer to work with both grouped and configurable products and also to ensure the CurrentStore is set appropriately. Please let me know if it works and accept the answer if it does.

    – BlueC
    Sep 12 '16 at 15:00











  • Hi @bluec I haven't had a chance to run this yet but I have a few questions. Do I need to replace ADMIN_STORE_ID with the appropriate store I'd? Can you run this so it changes all stores products not just the selected store? Also I don't have shell access could I run this through the browser?

    – Pragman
    Sep 12 '16 at 18:08











  • @ZUBU You can leave Mage_Core_Model_App::ADMIN_STORE_ID exactly as it is since without this the product changes won't save. It will already change the visibility of all products from all stores. However, if you have product visibility set differently for different store scopes and wish to override this too then this would need some changes. You could run it in the browser but I don't recommend it. To do so you'd need to move it out of ./shell/ into the root directory and then change include_once '../app/Mage.php'; to include_once 'app/Mage.php';

    – BlueC
    Sep 12 '16 at 19:56











  • I was somewhat successful with the script but the script seemed to stop and not loop through the entire catalog??? Also when I re ran the script it had the exact same output as before i.e. changing the visibility of products it had already changed. I tried clearing cache and reindexing to no avail. So after trying multiple clearing cache etc after running the script for the tenth time it still returns the same as the first time running it. I am running the script through the browser. Any ideas?

    – Pragman
    Sep 13 '16 at 7:51






  • 1





    Ok just tried clearing the storage cahce and rerunning and it got about twice as far. Leads me to believe it might be a memory or time out issue???

    – Pragman
    Sep 13 '16 at 7:54
















I have updated this answer to work with both grouped and configurable products and also to ensure the CurrentStore is set appropriately. Please let me know if it works and accept the answer if it does.

– BlueC
Sep 12 '16 at 15:00





I have updated this answer to work with both grouped and configurable products and also to ensure the CurrentStore is set appropriately. Please let me know if it works and accept the answer if it does.

– BlueC
Sep 12 '16 at 15:00













Hi @bluec I haven't had a chance to run this yet but I have a few questions. Do I need to replace ADMIN_STORE_ID with the appropriate store I'd? Can you run this so it changes all stores products not just the selected store? Also I don't have shell access could I run this through the browser?

– Pragman
Sep 12 '16 at 18:08





Hi @bluec I haven't had a chance to run this yet but I have a few questions. Do I need to replace ADMIN_STORE_ID with the appropriate store I'd? Can you run this so it changes all stores products not just the selected store? Also I don't have shell access could I run this through the browser?

– Pragman
Sep 12 '16 at 18:08













@ZUBU You can leave Mage_Core_Model_App::ADMIN_STORE_ID exactly as it is since without this the product changes won't save. It will already change the visibility of all products from all stores. However, if you have product visibility set differently for different store scopes and wish to override this too then this would need some changes. You could run it in the browser but I don't recommend it. To do so you'd need to move it out of ./shell/ into the root directory and then change include_once '../app/Mage.php'; to include_once 'app/Mage.php';

– BlueC
Sep 12 '16 at 19:56





@ZUBU You can leave Mage_Core_Model_App::ADMIN_STORE_ID exactly as it is since without this the product changes won't save. It will already change the visibility of all products from all stores. However, if you have product visibility set differently for different store scopes and wish to override this too then this would need some changes. You could run it in the browser but I don't recommend it. To do so you'd need to move it out of ./shell/ into the root directory and then change include_once '../app/Mage.php'; to include_once 'app/Mage.php';

– BlueC
Sep 12 '16 at 19:56













I was somewhat successful with the script but the script seemed to stop and not loop through the entire catalog??? Also when I re ran the script it had the exact same output as before i.e. changing the visibility of products it had already changed. I tried clearing cache and reindexing to no avail. So after trying multiple clearing cache etc after running the script for the tenth time it still returns the same as the first time running it. I am running the script through the browser. Any ideas?

– Pragman
Sep 13 '16 at 7:51





I was somewhat successful with the script but the script seemed to stop and not loop through the entire catalog??? Also when I re ran the script it had the exact same output as before i.e. changing the visibility of products it had already changed. I tried clearing cache and reindexing to no avail. So after trying multiple clearing cache etc after running the script for the tenth time it still returns the same as the first time running it. I am running the script through the browser. Any ideas?

– Pragman
Sep 13 '16 at 7:51




1




1





Ok just tried clearing the storage cahce and rerunning and it got about twice as far. Leads me to believe it might be a memory or time out issue???

– Pragman
Sep 13 '16 at 7:54





Ok just tried clearing the storage cahce and rerunning and it got about twice as far. Leads me to believe it might be a memory or time out issue???

– Pragman
Sep 13 '16 at 7:54

















draft saved

draft discarded
















































Thanks for contributing an answer to Magento Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f135763%2fset-all-child-products-to-not-visible-individually%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Disable / Remove link to Product Items in Cart Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?How can I limit products that can be bought / added to cart?Remove item from cartHide “Add to Cart” button if specific products are already in cart“Prettifying” the custom options in cart pageCreate link in cart sidebar to view all added items After limit reachedLink products together in checkout/cartHow to Get product from cart and add it againHide action-edit on cart page if simple productRemoving Cart items - ObserverRemove wishlist items when added to cart

Helsingin valtaus Sisällysluettelo Taustaa | Yleistä sotatoimista | Osapuolet | Taistelut Helsingin ympäristössä | Punaisten antautumissuunnitelma | Taistelujen kulku Helsingissä | Valtauksen jälkeen | Tappiot | Muistaminen | Kirjallisuutta | Lähteet | Aiheesta muualla | NavigointivalikkoTeoksen verkkoversioTeoksen verkkoversioGoogle BooksSisällissota Helsingissä päättyi tasan 95 vuotta sittenSaksalaisten ylivoima jyräsi punaisen HelsinginSuomalaiset kuvaavat sotien jälkiä kaupungeissa – katso kuvat ja tarinat tutuilta kulmiltaHelsingin valtaus 90 vuotta sittenSaksalaiset valtasivat HelsinginHyökkäys HelsinkiinHelsingin valtaus 12.–13.4. 1918Saksalaiset käyttivät ihmiskilpiä Helsingin valtauksessa 1918Teoksen verkkoversioTeoksen verkkoversioSaksalaiset hyökkäävät Etelä-SuomeenTaistelut LeppävaarassaSotilaat ja taistelutLeppävaara 1918 huhtikuussa. KapinatarinaHelsingin taistelut 1918Saksalaisten voitonparaati HelsingissäHelsingin valtausta juhlittiinSaksalaisten Helsinki vuonna 1918Helsingin taistelussa kaatuneet valkokaartilaisetHelsinkiin haudatut taisteluissa kaatuneet punaiset12.4.1918 Helsingin valtauksessa saksalaiset apujoukot vapauttavat kaupunginVapaussodan muistomerkkejä Helsingissä ja pääkaupunkiseudullaCrescendo / Vuoden 1918 Kansalaissodan uhrien muistomerkkim

Adjektiivitarina Tarinan tekeminen | Esimerkki: ennen | Esimerkki: jälkeen | Navigointivalikko