php - Magento: Need an if case for is a product name/sku/id is equal to X

968

Going to try to type this is the easiest way I can.

What I am looking to do is filter options I'm coding by hand (long story) by creating a large if statement of if elses.

IE: If the product sku=1234 then show the following. I'd only have about 14 products so this isn't as insane a thought as I had thought. But I can't seem to figure out the code I would need.

Please let me know if you'd need me to provide more details and any help is greatly appreciated.

Thank you

448

Answer

Solution:

if($product->getSku() == 12345)

What are you talking about!? :-)

You want to filter the products?

Build a observer, listen to the product_collection_load_before event, check the params sent to the action and then change the product_colletion where.

People are also looking for solutions to the problem: php - how to rewrite a url with two variables using .htaccess

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.