Download & Extend

Items added from views do not display in Shopping cart block as links

Project:Drupal Commerce
Version:7.x-1.x-dev
Component:Cart
Category:support request
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

This separation between Product and Product Display node has opened up a whole can of worms, although I'm sure there must have been some good reason for doubling the work of those who have to add 1000 product items and then another 1000 product nodes and then to match each single one of them.

By the way that's not how Amazon does it - there it seems to be some kind of simple Node-Reference which loads the product variant through ajax. Anyways.... (BTW, if there's an ongoing thread requesting to switch Commerce back to 1-node, please post a link cause I'd love to offer my 2 cents/pence as to why it should be done.)

Latest in the series of these "worms from the can" is that if you try adding to cart a product from views, in the Shopping cart it will appear as a text, whereas if you add to cart from the product page, then it will appear as a link. How do we deal with that?

Thanks?

Comments

#1

Version:7.x-1.1» 7.x-1.x-dev
Category:bug report» support request

If the Cart module can determine the context of the Add to Cart form when you add the product to the cart, it will add a link to it using the display path field on the product line item. Normally it pulls this from the node the Add to Cart form was displayed on. If you've just used the "Add to Cart form" Views field handler, then it may not be able to determine a reliable path to link the resulting line item to. The way around this within Views is to actually render the node in a Views field using a view mode that includes the Add to Cart form.

That said, there are dozens of threads discussing the product / product display issue if you search for them. It comes up all the time, and I really do try to communicate about it as much as humanly possible. For architectural reasons, there's no way we're ever going to revert to a hard relation to nodes with product data. If you review some of the threads and see exactly what it gains us, I can't imagine you'd think the problems that created are worth going back to. The usability issues are much easier to solve than the architectural issues, but no one has glibly decided to duplicate everyone's work. There are modules like Commerce BPC that aid in the bulk creation of products and assignation to product displays, even if they aren't perfect yet. I also have a contrib in the works to embed the full product form inside the node form (incidentally making it function much like you're suggesting without the mess we got into with SKU "adjustments" in Ubercart and multiple nodes per product).

In short - there are solutions and more solutions in development in contrib, but the core data model is fairly well set. We've tested and tried it in a variety of situations and haven't encountered a use case where it doesn't work, while we've had plenty where the former model wouldn't.

Back to the original issue, the real question is how have you built this View? Perhaps export it so we can reproduce the problem; usually I'd expect the line item to just link back to the View page itself.

#2

Hi: I'm wondering if someone can clarify the following for us laypeople:
"The way around this within Views is to actually render the node in a Views field using a view mode that includes the Add to Cart form."

We're having the same issue. Attached is the code from the view:

AttachmentSizeStatusTest resultOperations
view.odt4.22 KBIgnored: Check issue status.NoneNone

#3

@rszrama: would you mind explaining how the 'display path' is built when the Cart view is rendered and why it may 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.

Note: I haven't modified any code in commerce core other than to insert devel print statements to try and figure out what's going on. My code modifications are to the commerce_add_to_cart_extras module.

#4

@cyntaur in #2 :
The display path represent the _product display node_ from where you added the product to the cart.
If you added the product in a cart without being in a product display node, there is no way the system can define what node should be your display path, since you could potentially have more than 1 node referencing the product.

In other word, in a real store for instance : you could find the same product in multiple shelves (say an Ipod can be on the APPLE's PRODUCT SHELF _and_ on MP3 PLAYERS SHELF, to be sure you won't miss it ...). If you take it from APPLE's PRODUCT SHELF, the "display path" is APPLE's PRODUCT SHELF as this is where you took it from, same thing for MP3 PLAYERS SHELF.... Now imagine you're not taking it from here directly, but ask a salesman to get one from the stock warehouse : you're not following the regular "path" to get this product, so if I ask you to put the product back from where you took it, how do you do ? You can't since you're not allowed to get in the stock warehouse.

In this example : APPLE's PRODUCT SHELF and MP3 PLAYERS SHELF are 2 different product display referencing your iPod, and asking the salesman is using another way to put the product to the cart (order edition UI, or commerce_add_to_cart_extras)

When rszrama in #1 said

"The way around this within Views is to actually render the node in a Views field using a view mode that includes the Add to Cart form."

: if you create a view that renders product displays (which are referencing products), then you'll be able to have you display path filled up correctly, as the add to cart button have a reference.

Hope it helps !

#5

You can get a long way by using hook_commerce_product_uri. It will allow you to define the url for products.

#6

Hi @cyntaur did you solve your view to get the fields manipulative renderer in views? Instead of the complete entity?
I am only possible to get the complete node-object to be renderen in views through "content: rendered content" field.
I would very much like to be able to have the rendered views (products fields) individualy "formattable" like normal views fields.

EDIT: Hi. I solved my situation by using views displays of products. You can choose standard - full node - teaser etc.. and enable the appropriate fields!

greetings,
Martijn

#7

Subscribing!