0

We have an online tyre store with tyres as products and car models as categories. Since tyres can fit multiple cars, each tyre is mapped to all the car models where there is a fit.

However, each car model has certain original equipment tyres (those that come fitted from the factory on brand new cars). We would like to highlight such tyres on the listing page for the car model with a ribbon-style icon. The important point is that although a tyre can fit many car models, it may not be original fit for all of them (in practice it will be an original fit for only a few of them).

The strategy we have thought is to display all original fit tyres at the beginning on the listing pages by assigning them display positions less than 100. All other tyres, which also fit the car model but are not original fit are assigned display positions greater than 100. Therefore, simply being able to get the product position configured in the admin on the listing page would be sufficient to display an icon by checking if the position is less than 100.

I haven't been able to figure out how to get the product position on the listing page. The important part is that I should be able to read the position even if the user sorts by something other than the position, such as, name, price, etc.

  • If only one tire has to be marked as the factory fitted one and you can asure it's always on first position by your positioning idea, you could easily access it by CSS (ul.first li.first). But indeed it will mix up if your customer resorts the category. A better approach would be to give your product an custom attribute with comma-separated lists of category IDs to "shine" on. In your template file you can explode the list and check if one of its items matches the viewed category. The rest is CSS. Got it or need further help? – Nicolas Dec 24 '14 at 15:49
  • Many car models can have mutiple factory fit tyres, so the first tyre only cannot be taken as the original fit. I understand the other approach you have suggested and that is the fallback we have planned to use. Thanks for the feedback though. – manish.in.java Dec 24 '14 at 15:51
2

Found a solution for this on my installation of Magento CE 1.8.1.

  1. In the category, assign display positions exactly divisible by 10 to the products that are OE fit for that category.
  2. In the file app/design/{theme}/{sub-theme}/template/catalog/product/list.phtml get the product's position within the category as $_product->getCatIndexPosition().
  3. Check whether the retrieved value leaves a remainder of 0 when divided by 10. If it does, apply a watermark image to the product that indicates an original-fit tyre.

The key part was the $_product->getCatIndexPosition() call that provides access to a product's display position within a specific category.

I have tested this by changing the sort settings (sort by name, price, availability, position, etc.) and sort direction (ascending and descending) and the approach works fine in all cases.

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.