1

How is the 'display path' is built when the Cart view is rendered?
Why would it not be rendering some display path URLs?

I'm using a modified version commerce_add_to_cart_extras module whereby I'm trying to link the line item to the product display node by customizing the display path. I can see it being added correctly when I inspect the $line_item object in save function of CommerceLineItemEntityController. But the line items in my cart still aren't linked and when I output the display path as a field in the view, it's empty.

If it would help, I can add the debug print I captured via devel's dd() function of the $line_item or my code but they will make the post rather long so I've left them out for now.

2 Answers 2

2

Edit the view, click the "Quantity input field", are you sure the "Link products added to the cart from this View to this View's path if displayed as a page." checkbox is checked? That's what makes it populate the display path.

2
  • The display path is being populated, or at least I can see the display path populated when the $line_item is saved, but the links still aren't being rendered in the cart.
    – nmc
    Feb 16, 2012 at 3:10
  • Sorry I didn't answer your question. Yes, the checkbox is also checked in the View settings.
    – nmc
    Feb 16, 2012 at 19:53
0

Turns out this was my mistake. I thought the display_path was being populated and I was wondering why the line items in the cart were not being linked. But it turns out the display path is incomplete in the line item. Here's a comparison of the $line_item as saved via commerce core's add to cart form:

stdClass Object (
    [type] => product
    [order_id] => 7
    [quantity] => 1
    [data] => Array
        (
            [context] => Array
                (
                    [product_ids] => Array
                        (
                            [0] => 4369
                        )

                    [add_to_cart_combine] => 1
                    [display_path] => node/1839
                    [entity] => Array
                        (
                            [entity_type] => node
                            [entity_id] => 1839
                            [product_reference_field_name] => field_product_reference
                        )

                )

        ) 
...
    [commerce_display_path] => Array
        (
            [und] => Array
                (
                    [0] => Array
                        (
                            [value] => node/1839
                        )

                )

        ) 
...

vs. the commerce_add_to_cart_extras $line_item object:

stdClass Object
(
    [type] => product
    [order_id] => 12
    [quantity] => 1
    [data] => Array
        (
            [context] => Array
                (
                    [product_ids] => Array
                        (
                            [0] => 4375
                        )

                    [add_to_cart_combine] => 1
                    [display_path] => node/1845  //<--I modified to try and link to the display node
                    [view] => Array
                        (
                            [view_name] => products_by_category
                            [display_name] => page
                            [human_name] => Products by Category
                            [page] =>
                        )

                )
...

    [commerce_display_path] => Array
        (
            [und] => Array
                (
                    [0] => Array
                        (
                            [value] =>  // <--Turns out this is empty. Now, to figure out why/where to populate this...
                        )

                )

        )
...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.