Skip to content

Commit

Permalink
feat: Implement shop_view_url (#95)
Browse files Browse the repository at this point in the history
This URL is required for the shop components to create a link to article
in the cart

Note: core's `seoUrlToEntry` method has sadly currently some problems
and may not work correctly.
  • Loading branch information
sveneberth authored Mar 7, 2025
1 parent f5c5fd6 commit 9d31eea
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
11 changes: 11 additions & 0 deletions src/viur/shop/skeletons/article.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
import inspect
import typing as t # noqa

from viur.core import utils
from viur.core.bones import *
from viur.core.skeleton import BaseSkeleton

from viur.shop.types import *
from ..globals import SHOP_INSTANCE, SHOP_LOGGER
from ..types.response import make_json_dumpable
Expand Down Expand Up @@ -85,6 +87,15 @@ def shop_is_low_price(self) -> BooleanBone:
"""shop_price_retail != shop_price_recommended"""
...

shop_view_url = RawBone(
visible=False,
compute=Compute(
lambda skel: utils.seoUrlToEntry(skel.kindName, skel),
ComputeInterval(ComputeMethod.Always),
),
)
"""URL to the article page (view)"""

@property
def shop_price_(self) -> Price:
return Price.get_or_create(self)
Expand Down
7 changes: 0 additions & 7 deletions src/viur/shop/skeletons/cart.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,6 @@ class CartItemSkel(TreeSkel): # STATE: Complete (as in model)
# FIXME: What's necessary here?
parentKeys=["key", "parententry", "article"],
refKeys=[
"shop_name", "shop_description",
"shop_price_retail", "shop_price_recommended",
"shop_availability", "shop_listed",
"shop_image", "shop_art_no_or_gtin",
"shop_vat", "shop_shipping_config",
"shop_is_weee", "shop_is_low_price",
"shop_price_current",
"shop_*",
],
consistency=RelationalConsistency.CascadeDeletion,
Expand Down

0 comments on commit 9d31eea

Please sign in to comment.