Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hello there!
Is there any way to get product attribute SKUs? (on product page template)
What I would like to achieve is to show stock information for each product attribute, which are sizes of the product on my website.
Thanks!
Comments
Comment #1
TR CreditAttribution: TR commenteduc_product_get_models()
http://api.ubercart.me/api/drupal/ubercart!uc_product!uc_product.module/...
Comment #2
kevin_91 CreditAttribution: kevin_91 commentedHey, thanks for that, although I already tried this. It's almost perfect, I can get SKUs of the attributes but not in the right order.
For example:
Product - Organic Towel
Attribute - Size:
- Hand Towel (SKU: 6L-Z4LJ-YAON)
- Bath Towel (SKU: 1A-IHT6-JE3Y)
- Jumbo Bath Towel (SKU: B007DW316E)
When I try to get the SKUs what I get is:
0: 1A-IHT6-JE3Y
1: 6L-Z4LJ-YAON
2: B007DW316E
Is there any way to get attribute option ID maybe or something similar?
Comment #3
kevin_91 CreditAttribution: kevin_91 commentedComment #4
TR CreditAttribution: TR commentedLate response, but the answer is basically the same as what I said in your other issue #2462125: Show Attribute Option Stock
Specifically, attributes don't have SKUs. Instead SKUs may be assigned to any of the combinations of selected attribute options available on the product.
I believe that the default order of attributes should be the same as that shown on the node/%/edit/attributes page for that product. There are API functions in the uc_attribute module for looking up the option name based on the option ID.