Magento – When child product visibility is set to ‘Not visible individually’ don’t redirect to 404

configurable-productgoogle-product-feedsgoogle-shoppingsimple-product

For my store I want to create the situation where children of Configurable Products that are set to 'Not Visible Individually' are accessable anyway, when the direct URL is provided. Currently it returns a 404-error.

The purpose of this is, so we can only load the direct URLs in Google Shopping using Product Feeds, but not display the products in either Search or Catalog on the site.

I have no idea where to start. Can anyone help me out?

Update:

Using Marius' code from another question I created a module with the following code in /Namespace/Modulename/Model/Observer.php

<?php
     class Namespace_Modulename_Model_Observer {
        public function redirectToUrl($observer) {
            $id = Mage::app()->getRequest()->getParam('id');
            $_product = Mage::getModel('catalog/product')->load($id);

            $urlKey = $_product->getProductUrl($id);

            if (isset($urlKey)) {

            Mage::app()->getResponse()->setRedirect($urlKey, 301);
            Mage::app()->getResponse()->sendResponse();
            exit;
        }
        return $this;
    }
} ?>

This (obviously) sends the server in a loop, as I'm trying to send it to the simple product's page and Magento is trying to send it back to 404.

I think I'm very close to a solution, because all that needs to be done now (I think) is a way to overwrite Magento's default behavior of sending it to 404.

Any ideas?

Update #2

It's starting to seem that what I want is impossible and I can't find anything on the internet that can help me out.

Best Answer

This is not an answer to your question, but it may be a solution to your problem.
If you want the simple products to be accessible, you can just set their visibility to Catalog and don't assign them to any categories.
This way your simple product will not be found in search or by browsing the catalog.
They will only be accessible via direct URL, as you need it.

This way you can do it via the admin panel without any coding involved.

Related Topic