Creating a Related Products Block in Views Using a PHP Contextual Filter

Created on 15 September 2023, about 1 year ago

This case study details the systematic procedure to construct a block displaying related products on an eCommerce website. The approach utilizes Drupal's Views module and incorporates custom PHP code to effectively filter and display products based on taxonomy terms associated with a specific product. The steps encompass creating a View with a block display, establishing product display relationships, configuring display fields, implementing a contextual filter based on taxonomy terms, and incorporating a PHP-based filter to omit the currently viewed product from the related products list. This comprehensive methodology facilitates an organized and efficient approach to presenting related products within an eCommerce site.

💬 Support request
Status

Needs work

Version

1.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024