0

I want to show the SKU code on search result listing page. Like this https://support.3dcart.com/knowledgebase/article/View/269/6/how-do-i-add-the-product-idsku-to-my-search-results enter image description here Thanks everyone.

  • Hello Alex, welcome to Magento SE. What did you try so far? Show us the relevant codes – Rajeev K Tomy Sep 22 '15 at 0:59
2

In default Magento, the block Mage_Catalog_Block_Product_List is responsible for listing searching products as in category pages. The template file assoicated with this is catalog/product/list.phtml.

So basically you need to set a new template to this block. This is because the default template is using in various places in Magento and hence if you apply the changes in that file directly, it is going to view in every place. So replace this template with another template. This is how you can achieve this via layout update XML.

File : app\design\frontend\{package}\{theme}\layout\local.xml

<layout>
    <catalogsearch_result_index>
        <reference name="search_result_list">
            <action method="setTemplate">
                <template>custom/catalog/product.list.phtml</template>
            </action>
        </reference>
    </catalogsearch_result_index>
</layout>

Now copy paste the file in app\design\frontend\{package}\{theme}\template/catalog/product/list.phtml to app\design\frontend\{package}\{theme}\template/custom/catalog/product/list.phtml

In that file, you can see a foreach loop. put this code inside that loop in the exact place where you need to show your sku

<p><?php echo $_product->getSku() ?></p>

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.