• Toll-free  888-665-8637
  • International  +1 717-220-0012
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

arkestra
#1 Posted : Thursday, July 9, 2015 8:48:33 AM(UTC)
arkestra

Rank: Member

Joined: 7/9/2015(UTC)
Posts: 10

I have been successful in using the the Product Import script with modifications to add products to the Catalog. The process I used:

Quote:
// create choice
Dim choice = New Catalog.ProductChoice()

// set all choice values
choice.Type = "Drop Down List"

// add the choice to the product
product.ChoicesandInputs.Add(choice)

// add choice options to the choice, and commit
Dim choiceOption As Catalog.ProductChoiceOption = New Catalog.ProductChoiceOption()
choice.ChoiceOptions.Add(choiceOption)
choice.Commit()

However, I am not seing any entries being added to the bvc_ProductChoiceCombinations table. Will these combinations need to be created manualy, any which objects/methods would be used.

Thank you in advance for you help/clarification.
Ryan Groene
#2 Posted : Thursday, July 9, 2015 12:47:27 PM(UTC)
Ryan Groene

Rank: Member

Joined: 10/28/2014(UTC)
Posts: 11
United States
Location: Hummelstown, PA

Was thanked: 2 time(s) in 2 post(s)
First of all, do not call Commit on the newly created ProductChoice. This will get committed when you call commit on the Product object itself. After adding the choice to the product, call product.GlobalProduct.CreateCombinations() and then call Commit on the product object.

Here is sample code that I used to test this that worked:

Code:


        ' Create test product; obviously, you can also load an existing product here
        Dim p As New Catalog.Product
        p.Sku = "CTP"
        p.ProductName = "Choice Test Product"
        p.SitePrice = 5
        p.Commit()

        ' Create test choice
        Dim pc As New Catalog.ProductChoice
        pc.Name = "Choice 1"
        pc.DisplayName = "Choice 1"
        pc.Type = "Drop Down List"
        pc.ParentProductId = p.Bvin

        ' Create test choice options
        Dim pco1 As New Catalog.ProductChoiceOption
        pco1.DisplayText = "Option 1"
        pc.ChoiceOptions.Add(pco1)
        Dim pco2 As New Catalog.ProductChoiceOption
        pco2.DisplayText = "Option 2"
        pc.ChoiceOptions.Add(pco2)

        ' Add choice to product
        p.ChoicesAndInputs.Add(pc)
        p.GlobalProduct.CreateCombinations()
        p.Commit()

Edited by user Thursday, July 9, 2015 12:51:56 PM(UTC)  | Reason: Not specified

Ryan Groene
BV Commerce
Toll-free 888-665-8637 - Int'l +1 717-220-0012
 1 user thanked Ryan Groene for this useful post.
NP
arkestra
#3 Posted : Friday, July 24, 2015 11:35:13 AM(UTC)
arkestra

Rank: Member

Joined: 7/9/2015(UTC)
Posts: 10

Thanks...that seems to work now.

Is it possible to specify the choice option's associated product's SKU?

Additionally, how can stock for each of these choice options be set?

Sorry for the additional questions, but the documentation is severely lacking.

Thanks again!
arkestra
#4 Posted : Monday, July 27, 2015 12:18:21 PM(UTC)
arkestra

Rank: Member

Joined: 7/9/2015(UTC)
Posts: 10

I've found:

Code:
product.GlobalProduct.GetCombinationProducts


This seems to work OK.

However, it seems like the workflow should allow you to set the Price and SKU of the combo before committing it via the parent product. Otherwise, I have to loop through each of the created products after-the-fact.

Am I missing something?
Ryan Groene
#5 Posted : Monday, July 27, 2015 2:59:01 PM(UTC)
Ryan Groene

Rank: Member

Joined: 10/28/2014(UTC)
Posts: 11
United States
Location: Hummelstown, PA

Was thanked: 2 time(s) in 2 post(s)
Originally Posted by: arkestra Go to Quoted Post
I've found:

Code:
product.GlobalProduct.GetCombinationProducts


This seems to work OK.

However, it seems like the workflow should allow you to set the Price and SKU of the combo before committing it via the parent product. Otherwise, I have to loop through each of the created products after-the-fact.

Am I missing something?



The child products are not actually created until you commit the parent product, so you have to commit the parent product first and then loop through or look up the desired child product to change the information.

This corresponds to how it works in the admin: Combinations are created automatically as choices and options are added and taken away. By default, the information for the child products is pulled from the parent product, but it can then be edited for individual child products.

The function that you are using here (GetCombinationProducts) will work if you want to get all combinations and then loop through them. If you want to get a specific choice combination product (corresponding to a specific combination of options), you can use

Code:

Dim pcc As Catalog.ProductChoiceCombination = p.GlobalProduct.GetChoiceCombinationForChoices(keys)
Dim comboProduct As Catalog.Product = Catalog.InternalProduct.FindByBvin(pcc.Bvin)


Where keys is a Collection of Strings representing each of the option bvin's.

The inventory can be edited similarly by modifying comboProduct.Inventory and then calling ProductInventory.Update. It's important to note though that if you are editing inventory, the product's TrackInventory property must be set to True beforehand.

Edited by user Monday, July 27, 2015 3:02:06 PM(UTC)  | Reason: Not specified

Ryan Groene
BV Commerce
Toll-free 888-665-8637 - Int'l +1 717-220-0012
arkestra
#6 Posted : Monday, July 27, 2015 3:15:10 PM(UTC)
arkestra

Rank: Member

Joined: 7/9/2015(UTC)
Posts: 10

OK - trying this out now.

I don't see ProductInventory.Update, is it not in BVSoftware.Bvc5.Core?

Will comboProduct.Commit() run the ProductInventory update?

Thanks again!
arkestra
#7 Posted : Monday, July 27, 2015 3:16:13 PM(UTC)
arkestra

Rank: Member

Joined: 7/9/2015(UTC)
Posts: 10

Also, comboProduct.Inventory is read-only (for some reason).

There's comboProduct.SetAvailableQuantity(), but that does nothing as far as I can tell.

For updateing inventory, is the following correct?

Code:

Dim inventory As New Catalog.ProductInventory
Catalog.ProductInventory.Update(inventory)


Activating the inventory tracking works as expected, and if the stock is incremented through the admin interface, it all works as expected.

Edited by user Monday, July 27, 2015 3:38:29 PM(UTC)  | Reason: Not specified

arkestra
#8 Posted : Monday, July 27, 2015 3:49:38 PM(UTC)
arkestra

Rank: Member

Joined: 7/9/2015(UTC)
Posts: 10

Got it by following Product_Edit_Inventory.aspx.vb...

Code:

Dim quantity As Integer = 12
Dim inventory As New Catalog.ProductInventory

comboProduct.Inventory.ProductBvin = comboProduct.Bvin

Catalog.ProductInventory.Insert(comboProduct.Inventory)

comboProduct.AdjustAvailableQuantity(quantity)


Thanks for the pointers!
Aaron
#9 Posted : Tuesday, July 28, 2015 9:21:56 AM(UTC)
Aaron

Rank: Administration

Joined: 4/2/2004(UTC)
Posts: 2,393
United States
Location: Hummelstown, PA

Thanks: 6 times
Was thanked: 163 time(s) in 158 post(s)
Originally Posted by: arkestra Go to Quoted Post
Also, comboProduct.Inventory is read-only (for some reason).

This just prevents you from assigning a new inventory object to the product object; you can still edit the properties of the inventory object (e.g. choiceProduct.Inventory.QuantityAvailable = 12).

Originally Posted by: arkestra Go to Quoted Post
There's comboProduct.SetAvailableQuantity(), but that does nothing as far as I can tell.

Did you check the database? It should be updating the values in the database. However, it doesn't look like it updates the object when it updates the database (which it should...so that's something that we should correct).

Originally Posted by: arkestra Go to Quoted Post
For updateing inventory, is the following correct?

Code:

Dim inventory As New Catalog.ProductInventory
Catalog.ProductInventory.Update(inventory)

That looks like it should work. As you can see, there are multiple ways to achieve the same result.
Aaron Sherrick
BV Commerce
Toll-free 888-665-8637 - Int'l +1 717-220-0012
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

©2024 Develisys. All rights reserved.
  • Toll-free  888-665-8637
  • International  +1 717-220-0012