Set all child products to not visible individuallySet all associated product not visible individuallyQuery if a product is set to be visible on the websiteConfigurable products not shown in searchMagmi import configurables don't associate simplesNot Visible Individually Still Showing In Search ResultsMake Products Non-VisibleSave all products through php/shell scriptHow to diagnose “Invalid block type ” error?Magento simple products not visible individually still show upHow to set related products show num?

How to preserve electronics (computers, ipads, phones) for hundreds of years?

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

Trouble reading roman numeral notation with flats

Do I have to take mana from my deck or hand when tapping this card?

Taking the numerator and the denominator

Would this string work as string?

Offset in split text content

Is this saw blade faulty?

Why is participating in the European Parliamentary elections used as a threat?

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

Magnifying glass in hyperbolic space

How do you justify more code being written by following clean code practices?

Make a Bowl of Alphabet Soup

What properties make a magic weapon befit a Rogue more than a DEX-based Fighter?

Connection Between Knot Theory and Number Theory

Why is indicated airspeed rather than ground speed used during the takeoff roll?

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

How do you say "Trust your struggle." in French?

How would a solely written language work mechanically

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

Is there a distance limit for minecart tracks?

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

Can a Knock spell open the door to Mordenkainen's Magnificent Mansion?

How to test the sharpness of a knife?



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 websiteConfigurable products not shown in searchMagmi import configurables don't associate simplesNot Visible Individually Still Showing In Search ResultsMake Products Non-VisibleSave all products through php/shell scriptHow to diagnose “Invalid block type ” error?Magento simple products not visible individually still show upHow to set related products show num?













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 19 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

Nidaros erkebispedøme

Birsay

Was Woodrow Wilson really a Liberal?Was World War I a war of liberals against authoritarians?Founding Fathers...