1

I want to refrain from using the import export, we have a LARGE amount of products (5,000)

Basically, I have done some heavy configuration the the templates to display the catalogue in a very wholesale way for our client, if you want to look it is here (www.musclefinessewholesale.com) however, you will not be able to see any of the formatting unless you are logged in and you wont be able to register as it is trade only. So, basically EVERY product has a Grouped product, then flavours are set up as simple products which are associated with this product.

I understand this is not the best way sometimes to do things but it fitted the bill so to speak. The issue is Every simple product shows up when you click on the mater categories (brands) but we only want to display the grouped product.

Can anyone explain using API how I may find ALL of the simple products in Magento and then change the visibility to hidden individually. This way they will only show as part of the master.

Please see attached what it looks like to get your head around the format: This is how we have it looking

However, This is what happens when a user searches for a pruct (These are the simple products we need hiding on MASS) enter image description here

ANy ideas how I can write a API loop to go through EVERY simple product in the system and set the visibility to Not Visible Individually?

4

1 回答 1

0

试试这个,我知道这不是使用 SOAP-API,但它直接挂在 Magento 中。

require_once($_SERVER['DOCUMENT_ROOT'] . '/app/Mage.php');
umask(0);

// Retrieve store-codes
$storelist = Mage::app()->getStores();
$storelang = array();
foreach ($storelist as $id => $s) {
    $storelang[$id] = substr(Mage::getStoreConfig('general/locale/code', $id), 0, 2);
}
...
$storeId = Mage::app()->getStore()->getId();
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$pModel = Mage::getModel('catalog/product');
$products = $pModel->getCollection();
foreach ($products as $product) {
    if ($product->isConfigurable()) {
        $childProducts = Mage::getModel('catalog/product_type_configurable')
                ->getUsedProducts(null, $product);
        foreach ($childProducts as $child) {
            foreach ($storelang as $lang_key => $lang_value) {
                $child->setStoreId(Mage::app()->getStore($lang_value)->getId());

                // 1 = not visible individually
                // 2 = catalog
                // 3 = search
                // 4 = catalog + search

                $child->setVisibility(1);
                try {
                    $child->save();
                } catch (Exception $e) {
                    echo $e->getMessage();
                }
            }
        }
    }

如果您有任何问题,请随时与我们联系。我希望这有帮助。一切顺利。

于 2014-05-09T09:10:31.747 回答