Inventory Admin Modification

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
wilhud
Lieutenant (LT)
Lieutenant (LT)
Posts: 66
Joined: Mon Mar 30, 2009 7:44 pm

Inventory Admin Modification

Post by wilhud » Wed Sep 30, 2009 12:10 pm

I am attempting to add a SKU column to the inventory admin and then trying to get it to be sortable. So far I have made these modifications to the Admin/Catalog/Inventory.aspx page...

Code: Select all

// Get the corresponding Sku info
protected string GetSku(object dataItem)
    {
        ProductInventoryDetail detail = (ProductInventoryDetail)dataItem;
        if (detail.ProductVariantId.Equals(0)) {
        	Product product = ProductDataSource.Load(detail.ProductId);
        	return product.Sku;
        } else {
        	ProductVariant variant = ProductVariantDataSource.Load(detail.ProductVariantId);
        	return variant.Sku;
        }
    }

Code: Select all

// Display the Sku info
<asp:TemplateField HeaderText="Sku" SortExpression="Sku">
                            <ItemTemplate>
                                <asp:HyperLink ID="SKULink" runat="server" Text='<%# GetSku(Container.DataItem) %>' NavigateUrl='<%#Eval("ProductId", "../Products/EditProduct.aspx?ProductId={0}")%>'></asp:HyperLink>
                            </ItemTemplate>
                            <HeaderStyle HorizontalAlign="Left" />
                        </asp:TemplateField>
That pulls the proper SKUs and displays them on the page next to their corresponding Product Names. However, it does not sort on the SKU column. Pops up the error "Exception has been thrown by target of invocation." I'm sure it's because I have not added the proper coding to do the sort by Sku, but how would I do that? Is it something that is possible to do in the source code or would it require modifications to the app itself?

Any ideas or suggestions are appreciated.

Thanks,
Wil

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: Inventory Admin Modification

Post by AbleMods » Thu Oct 01, 2009 5:20 am

wilhud wrote:So far I have made these modifications to the Admin/Catalog/Inventory.aspx page...
I'm not finding this page in 7.0.3, are you talking about the Low Inventory page?

If so, I think your situation is much more complex.

Since the "sku" value is really dynamic, you can't sort it unless you create a custom class. In your situation, the sku value is being pulled from multiple sources via your code-behind function. As a result, the sku value isn't really "stored" in the data, it's just being displayed in the grid column. Therefore the server-side code has nothing to sort.

Able tends to use custom data classes to construct and populate certain reports on the admin side. While this makes certain design aspects easier, it makes it far more complicated to modify after-the-fact. In your situation, your only two options are both complex:

1. Buy full source code and modify the report data class to include the SKU value. Then your code mods will work because a true "sku" data field will exist in the report data. Your code-behind to pull in the sku will be moved into the able API code that populates the report data class.

2. Redesign the entire Low Inventory page to work with your own custom-designed data class. Ugh is the first thought that comes to mind :)
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Inventory Admin Modification

Post by mazhar » Thu Oct 01, 2009 5:59 am

Have a look at following threads
viewtopic.php?f=44&t=8713
viewtopic.php?f=44&t=9101

wilhud
Lieutenant (LT)
Lieutenant (LT)
Posts: 66
Joined: Mon Mar 30, 2009 7:44 pm

Re: Inventory Admin Modification

Post by wilhud » Thu Oct 01, 2009 10:29 am

I probably don't have enough time to learn and write an entire data class, so I guess listing the skus will have to suffice for now. However, I do think I'll need to make a filter where the user can type in a sku or partial sku and get the corresponding results. I'm going to start working on that instead. If anyone has a starting point for something like that it would be much appreciated. Otherwise, I'll post it here when I'm finished.

Thanks,
Wil

wilhud
Lieutenant (LT)
Lieutenant (LT)
Posts: 66
Joined: Mon Mar 30, 2009 7:44 pm

Re: Inventory Admin Modification

Post by wilhud » Fri Oct 02, 2009 6:48 pm

Would it be possible to use a DataView on the Inventory report? That way the Sku field could be added into the results and sorted properly and the DataView is displayed in the grid, rather than initial results without the sku column.

Pardon me if I'm completely wrong in my assumptions, I'm very new to C# and to AbleCommerce. It's just based on some things I've found online, where it seems like it could work but when I tried it, I got an error saying DataView was not understood. So I'm not sure how to alleviate that. I'm guessing it would need to be loaded somehow, but that's way above my head right now.

Thanks,
Wil

Post Reply