store/1, user/1, node/1

Created on 14 May 2024, 7 months ago
Updated 9 July 2024, 5 months ago

Problem/Motivation

Display Drupal Commerce products of a store on the store page at /store/ID.

Not quite sure if it is a bug or it's me misunderstanding the module configuration options. My assumptions were if the "Provide a static URL segment(s) to prefix aliases?" is set as "store" ( or "node" or "user" for that matter) than things should start working. Please see below for detailed description.

Steps to reproduce

- Have a Commerce store at /store/1 and a User at user/1 and a node at node/1
- Create a Commerce Products block aiming to display products of the store on the store page (store/1).
- For the block, configure contextual filter: Store: ID
- Set a filter as usual: "provide default value > entity ID converted from .."
-- [optional] set the "Provide a static URL segment(s) to prefix aliases?" = "store" for the filter value and validation criteria - in both places or separately, doesn't seem to make any difference
- Place the block and see it at every url ending at "1" : store/1, node/1, user/1

There are notices in Watchdog after tests for non-existent node at node/11, perhaps not relevant and not worth a separate issue creation.
Deprecated function: ctype_digit(): Argument of type null will be interpreted as string in the future in Drupal\views_url_path_arguments\Plugin\views\argument_default\UrlPath->getArgument() (line 124 of /modules/contrib/views_url_path_arguments/src/Plugin/views/argument_default/UrlPath.php)

***
Apache, PHP 8.2.18, Drupal 10.2.

🐛 Bug report
Status

Active

Version

1.2

Component

Code

Created by

🇸🇰Slovakia yurg

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

Comments & Activities

  • Issue created by @yurg
  • 🇫🇮Finland phonkala

    Hey @yurg!

    In your use case, I don't think you are using paths at all. Actually, you propably don't even have path aliases on those, based on your example having those IDs in the URL. I mean, aren't the store/1, user/1 and node/1 just default routes with entity id at the end? I think you could just use the basic entity ID (or user ID etc) as the contextual filter and it would work.

    For my use case, let's say I got content types "Activity Tracker" and "Activity". I add new "Activity Tracker" called "Fitness Log". For my "Activity Tracker" content type, I set the pathauto pattern to be "/activity-trackers/[node:title]", instead of "/activity-trackers/[node:nid]".

    So basicly, I wanted to list all the "Activities" added to that "Fitness Log" activity tracker in "/activity-trackers/fitness-log/activities", instead of the basic "/activity-trackers/1/activities". For this I needed a way to get the entity id from path alias, as the ID wasn't in the URL.

    For your use case, I think you would need this module if you want your stores have the name of the store in the URL, for example "/store/my-store" (store ID 1). Then, you could make a View page with path "/store/%/products" and if you used the contextual filter to be converted from path alias, you could access the products via "/store/my-store/products" instead of "/store/1/products".

Production build 0.71.5 2024