Posted by fago on January 15, 2013 at 3:37pm
6 followers
Jump to:
| Project: | Drupal Commerce |
| Version: | 7.x-1.x-dev |
| Component: | Cart |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
Attached patch makes it possible to re-use the existing "add to cart button" views field with other views query engines, e.g. search api views. That works via the views_handler_field_entity which allows for rendering any entity fields via a loaded entity regardless of the back-end.
| Attachment | Size | Status | Test result | Operations |
|---|---|---|---|---|
| d7_commerce_product_search_api_views.patch | 2.82 KB | Idle | PASSED: [[SimpleTest]]: [MySQL] 3,570 pass(es). | View details |
Comments
#1
Using Commerce Kickstart, applied patch, cleared cache, but when I go to Fields in Views admin for the Products search api view the Add to Cart form is not available
#2
Patch in OP worked brilliantly for me. Thanks!
#3
I'm not sure I understand the move from the base entity tables to the views_entity_* tables for these two fields. Is that a requirement, or would using the handler be sufficient?
#4
The handler takes care of loading the entity via the used Views query class, while the changed base table makes sure the field is available for every Views base table that declares itself to list the given entity type.
Thus, it would work without moving the base table if you manually take care of registering the field. But that's hard to do generally, and Views has a built-in mechanism for that instead. So let's better use that - thanks to the "moved to" features it's totally BC.
#5
PS : Nevermind, after adding the Product relationship, the Add to Cart form appeared.
@jwilson3 and @fagoCare to share the steps one should take to get this going? I applied the patch but even after clearing cache I am only seeing the regular Search API indexed product fields in the Views Field list like:Product: Product ID (indexed)The internal numeric ID of the product.
Product: SKU (indexed)
The human readable product SKU.
Product: Title (indexed)
The title of the product.
No Shopping cart or Add to Cart...#6
Ok, cool. This worked fine for me, and I love the Views "moved to" feature. Feel free to point out other areas you think we can use such an improvement.
#7
Nice (crucial) improvement. Thanks Fago for the patch and Ryan for the commit!
#8
Automatically closed -- issue fixed for 2 weeks with no activity.