GetUpsellProducts() throws a null exception if ChildProductId is not found

Found an interesting problem with my AbleCommerce 7.0.3 installation after doing a test upgrade to 7.0.5 last night.

My add to cart button wouldn’t work after the upgrade.  It kept saying Object reference blah blah blah.  Put everything into the debugger and figured out I have some bad data in the storefront.

I had several (384 to be exact) ChildProductId’s assigned to real products in the ac_UpsellProducts table.  Upsells are products that are advertised after the original product is added to the cart.  Obviously you wouldn’t want to upsell a product that no longer exists – thus there’s a foreign key constraint on the ProductId.  That way, any products that get deleted automatically delete their link in any upsell products and visa versa.

Somehow in my data, that wasn’t happening.  I have products assigned as an upsell to a main product, and those products no longer exist.  This was causing addtocartlink.ascx to throw a null reference exception when it hit the GetUpSellProducts method.

Easy fix is to just clean out any bad upsells using this query:

delete ac_upsellproducts

from ac_upsellproducts

left outer join ac_products on ac_upsellproducts.childproductid = ac_products.productid

where ac_products.productid is null


How to show same categories on every page

You may have noticed by now that AbleCommerce 7 does not show all categories in the left side menu.  Once you drill into a sub-category, the left side shows you only sub-categories from that point forward in the store catalog.  AC7 makes it a tad confusing since now you don’t really know how to go back up unless you notice the breadcrumbs.

That’s swell if you have a sufficiently large catalog tree.  Many stores do not have a large one.  They would like to see all categories on every page that uses the Left Sidebar 1.  This is incredibly simple to implement.

Edit your Left Sidebar 1 scriptlet.  You can do this from either the Admin side or by switching to Edit Mode on the visitor side ( assuming you’re logged in as an admin).

the Left Sidebar 1 defaults to:

Just change it to:
[[ConLib:SimpleCategoryList CategoryId=”0″]]

Now save your change.  You’ll see the results immediately – the category list control will always pull from the root level of the catalog to display all sub-categories at level 1.  Suweet !!