How to list bundle product items in transformation

benyamin jain asked on February 25, 2016 09:33

HI

Is there any way to list bundle product items in transformation?

Correct Answer

Trevor Fayas answered on February 25, 2016 15:33

From a database standpoint, the relationship for Bundles is that a SKU has a type (in this case, "BUNDLE"), and then the COM_Bundle has the BundleID (the SKUID of the bundle typed sku) and SKUID (of the bundled item) to relate the other items.

So you're probably going to need to do a nested repeater (unless you do some fancy work mimicking page types and parent-child structure in a query and utilize the Universal Viewer with Custom Query, which is a bit more advanced).

The repeater of the SKUs would look something like this:

My Bundle Sku: <%# Eval("SKUName") %>
<ul>
    <cms:QueryRepeater runat="server" ID="subItems" QueryName="ecommerce.sku.selectall" TransformationName="My.Custom.BundleSkuListTransformation" />
</li>

<script runat="server">
protected override void OnInit(EventArgs e)
    {
        // Grabs child skus that are bundled under this one.
        subItems.WhereCondition = "SKUID in (Select SKUID from COM_Bundle where BundleID = "+Eval<int>("SKUID")+")";
    }
</script>
1 votesVote for this answer Unmark Correct answer

   Please, sign in to be able to submit a new answer.