0

I want to create a default product reference with the price to zero, title to node_title, sku to author_node_title. So each time I create a display product node type I haven't to fill the product reference info. If I created one display product node type -> system will create one product and auto reference that product to display product node.

Thanks in advance!

3 Answers 3

1

You could use a triggered rule using Rules on the event "After saving new content", creating the product entity, saving it and editing the product reference field after as well.

3
  • I tried this but didn't success. Can you share your rule for this case?
    – Tran Huy
    Commented Jul 11, 2012 at 7:16
  • Sure thing. Check here pastebin.com/dnP39X4P. It's actually quite simple and you only need 2 conditions (check if the saved node is of the correct type and if it has the product reference field) and 3 actions (create the product entity, save it and set the data value of the reference field to the product you just created. Rules + Entity API is quite powerful!
    – mariomc
    Commented Jul 11, 2012 at 11:50
  • Thanks for you help! I did extractly the same to you without success. Then I write a simple module for my case.
    – Tran Huy
    Commented Jul 12, 2012 at 8:26
1

Why don't you do the opposite? When you create a product, a display is also created.

Commerce Bulk Product Creation

1
  • Thanks for you answer, My site have a specific requirement. I want the user can post product to the site without access to admin store.
    – Tran Huy
    Commented Jul 11, 2012 at 7:15
0

Just use the 'Auto Product Display' module which simply Product Display creation process by providing option the create it at the same time with Product creation.

Features

  • Provide the Product Display creation form along with the Product creation form. User can fill that form to create Product Display at
    the same time with Product creation.
  • That form, which used to create Product Display, will be the same as the form when user try to create Product Display manually. So, If you have additional fields in your Product Display node type, those fields will also appear in the form.
  • If the product is referenced by only one Product Display, the Product Display content is displayed directly to the form, so it will be automatically updated when you save the product.
  • If the product is referenced by more than one Product Display, the referencing Product Displays will be displayed in list, so you can
    also update the Product Display by clicking the link from that list
    first.

Your Answer

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

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