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

Can not update quote_id field of “quote_item” table magento 2Magento 2.1 - We can't remove the item. (Shopping Cart doesnt allow us to remove items before becomes empty)Add value for custom quote item attribute using REST apiREST API endpoint v1/carts/cartId/items always returns error messageCorrect way to save entries to databaseHow to remove all associated quote objects of a customer completelyMagento 2 - Save value from custom input field to quote_itemGet quote_item data using quote id and product id filter in Magento 2How to set additional data to quote_item table from controller in Magento 2?What is the purpose of additional_data column in quote_item table in magento2Set Custom Price to Quote item magento2 from controller

Magento 2 disable Secret Key on URL's from terminal The Next CEO of Stack OverflowMagento 2 Shortcut/GUI tool to perform commandline tasks for windowsIn menu add configuration linkMagento oAuth : Generating access token and access secretMagento 2 security key issue in Third-Party API redirect URIPublic actions in admin controllersHow to Disable Cache in Custom WidgetURL Key not changing in Magento 2Product URL Key gets deleted when importing custom options - Magento 2Problem with reindex terminalMagento 2 - bin/magento Commands not working in Cpanel Terminal

Aasi (pallopeli) Navigointivalikko