1

now I created configurable product including many simple product, each simple has own SKU. but once user search on website, they only search configurable product SKU can't find associates SKU.

In case I want user can search all associates SKU and showing result as configurable product is it possible to do ?

because when I set simple visible to "search", it work but it show product as simple.

ex: I have 1 configuration SKU "test0" including 3 simple which are "test1, test2, test3"

now when user search weather "test1 or test2 or test3" it must show "test0" as result

Can I set this result by default magento system? Thanks so much

1

Bit old post though, I this to search a configurable product from it's child sku. My solution might be useful to someone.

I simply appended all the child SKUs in catalogsearch_fulltext table rows.

First change the search configuration:

System > Catalog > Catalog Search > Search Type to "Combine (Like & Fulltext)

add event observer for catalogsearch_reset_search_result

add this code in event observer class method

/**
 * Append these $childSKUs to fulltext 
 * db table catalogsearch_fulltext.data_index 
 * field with '|' seperated
 */
$fulltextCollection = Mage::getModel('catalogsearch/fulltext')->getCollection()
    ->addFieldToFilter('type_id', array('neq' => 'simple'));
$fulltextCollection->load();

$resource = Mage::getSingleton('core/resource');
$writeConnection = $resource->getConnection('core_write');
$tableName = $resource->getTableName('catalogsearch/fulltext');

foreach ($fulltextCollection as $fulltext) {
    $childSKUs = array();
    $fulltext = Mage::getModel('catalogsearch/fulltext')->load($fulltext->getId(), 'product_id');
    $p = Mage::getModel('catalog/product')->load($fulltext->getId());

    if ($p->getTypeId() == 'configurable') {
        $childrenIds = $p->getTypeInstance()->getUsedProductIds();
        $childrenSKUs = Mage::getResourceModel('catalog/product')->getProductsSku($childrenIds);
    }

    if (isset($childrenSKUs)) {
        foreach($childrenSKUs as $c){
            $childSKUs[] = $c['sku'];
        }
    }

    $dataIndex = $fulltext->getDataIndex();
    if (count($childSKUs)) {
        $dataIndex .= '|' . implode('|', $childSKUs);
    }

    /**
     * Have to use update query instead of model
     * fulltext resource uses product_id as key field
     * but fulltext_id is the primary key, so while 
     * updating through model it gives primary key duplicate error
     */
    $writeConnection->query(
        "UPDATE $tableName SET data_index = :data_index
        WHERE product_id = :product_id", array(
            'product_id' => $fulltext->getId(),
            'data_index' => Mage::helper('core')->escapeHtml($dataIndex)
        )
    );
}
0

By default, the child product's SKU doesn't work in Catalog Search. You will not get the parent product in search result when you search by child product's SKU.

One simple solution to this can be:

  • Create a new textField attribute named children_sku, for example.
  • Make it searchable, i.e. Use in Quick Search = Yes
  • Assign this newly created attribute to your attribute set.
  • Now, while editing configurable product, add comma separated child products SKU in the children_sku attribute text field.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.