Product Qty Price
Your Shopping Basket Is Currently Empty.

Sub Total: £0.00
Hide Panel

AspDotNetStorefront Manufacturer Name and Image On Product Pages

Dot Net Developments Blog RSS Feed
Sadly AspDotNetStorefront can not display the current manufacturer of a product on the product page. However we have the perfect fix for that which works in all version of AspDotNetStorefront.

First we are going to add a query to the product XML. This snippet of code is to go before <PackageTransform> and after </query>.

So once you have a nice space you want to paste in:

<!-- MANUFACTURER INFO -->
  <query name="Manufacturers" rowElementName="Manufacturer">
    <sql>
      <![CDATA[ 
            SELECT TOP 1 m.ManufacturerID, m.Name AS ManufacturerName,  m.SEName AS ManufacturerSEName 
            FROM dbo.Product p INNER JOIN 
              dbo.ProductManufacturer pn ON @ProductID = pn.ProductID INNER JOIN 
              dbo.Manufacturer m ON pn.ManufacturerID = m.ManufacturerID 
        ]]>
    </sql>
    <queryparam paramname="@ProductID" paramtype="request" requestparamname="ProductID" sqlDataType="int" defvalue="0" validationpattern="" />
  </query>
<!-- END MANUFACTURER INFO -->

A quick talk through this code, first it is a basic select call from the database, however we have defined we only want the first result returned back, this is just in case! We are calling the Manufacturer ID, the Manufacturer SEName (for building links) and the Manufacturer Name!

We get this information by looking at what product is on the page and tracking back.

Once this is done you have access to the building blocks for Manufacturer Images and Links.

We use this to generate a link.

First how to get just the Manufacturer Name to display on the page

<xsl:value-of select="/root/Manufacturers/Manufacturer/ManufacturerName" disable-output-escaping="yes" />

That will display the Manufacturer's Name!

For creating a link...

<a href="{aspdnsf:EntityLink(/root/Manufacturers/Manufacturer/ManufacturerID, /root/Manufacturers/Manufacturer/ManufacturerSEName, 'Manufacturer', 0)}" title="View All {/root/Manufacturers/Manufacturer/ManufacturerName} Products">
   <xsl:value-of select="/root/Manufacturers/Manufacturer/ManufacturerName" disable-output-escaping="yes" /> 
</a>

This code creates a link with the Manufacturer Name as what is displayed, also hovering over the link brings up "View All {ManufacturerName} Products".

That is how you create a link.

Now for getting an image

<xsl:value-of select="aspdnsf:LookupImage('Manufacturer',/root/Manufacturers/Manufacturer/ManufacturerID,'','', 'icon', '0')" disable-output-escaping="yes" />

Perfect!

Now you can do anything you need with a Manufacturer on any Product Page!

If you need more information you can expand the query very easily. To access anything inside the query just use /root/Manufacturers/Manufacturer/FIELDNAME.
20/07/2011

By Dot Net Developments