Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 4 of 4

Thread: Adding Open Graph Meta Tags For Pinterest and Facebook 'Semantic Markup'

  1. #1
    bashdaddy is offline Junior Member
    Join Date
    Jan 2010
    Posts
    6

    Default Adding Open Graph Meta Tags For Pinterest and Facebook 'Semantic Markup'

    I'm trying to pull in all the required information for Pinterest and Facebook into my <head> section of my template by using a xml package. I have everything working accept for the product information for Price, UPC, and Brand. Can someone help me out by adding what I'm missing to get this information to pull?

    What is in bold is the sections that I can't get to pull any data. I'm sure this is a simply fix but I really don't know what I'm doing. Any help would be great.
    <?xml version="1.0" standalone="yes" ?>
    <package version="2.1" displayname="Facebook OpenGraph Tags" debug="false" includeentityhelper="false">

    <query name="Products" rowElementName="Product">
    <sql>
    <![CDATA[
    SELECT ProductID, Name, SEDescription, ImageFileNameOverride, SKU FROM Product WHERE ProductID = @ProductID
    ]]>
    </sql>
    <queryparam paramname="@ProductID" paramtype="request" requestparamname="ProductID" sqlDataType="int" defvalue="0" validationpattern="^\d{1,10}$" />
    </query>

    <PackageTransform>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:aspdnsf="urn:aspdnsf" exclude-result-prefixes="aspdnsf">
    <xsl:output method="xml" omit-xml-declaration="yes" />

    <xsl:template match="/">

    <xsl:param name="image_link">
    <xsl:choose>
    <xsl:when test="boolean(/root/Products/Product/ProductID)">
    <xsl:value-of select="aspdnsf:ProductImageUrl(/root/Products/Product/ProductID, /root/Products/Product/ImageFileNameOverride, /root/Products/Product/SKU, 'medium', 'true')" />
    </xsl:when>
    <xsl:otherwise>0</xsl:otherwise>
    </xsl:choose>
    </xsl:param>

    <xsl:param name="prod_name">
    <xsl:choose>
    <xsl:when test="boolean(/root/Products/Product/ProductID)">
    <xsl:value-of select="/root/Products/Product/Name"/>
    </xsl:when>
    <xsl:otherwise>0</xsl:otherwise>
    </xsl:choose>
    </xsl:param>

    <xsl:param name="item_price">
    <xsl:choose>
    <xsl:when test="boolean(/root/Products/Product/ProductID)">
    <xsl:value-of select="/root/Products/Product/Price"/>
    </xsl:when>
    <xsl:otherwise>0</xsl:otherwise>
    </xsl:choose>
    </xsl:param>

    <xsl:param name="item_upc">
    <xsl:choose>
    <xsl:when test="boolean(/root/Products/Product/ProductID)">
    <xsl:value-of select="/root/Products/Product/UPC"/>
    </xsl:when>
    <xsl:otherwise>0</xsl:otherwise>
    </xsl:choose>
    </xsl:param>

    <xsl:param name="item_brand">
    <xsl:choose>
    <xsl:when test="boolean(/root/Products/Product/ProductID)">
    <xsl:value-of select="/root/Products/Product/Brand"/>
    </xsl:when>
    <xsl:otherwise>0</xsl:otherwise>
    </xsl:choose>
    </xsl:param>


    <xsl:variable name="FBDesc" select="/root/Products/Product/SEDescription" />


    <xsl:choose>
    <xsl:when test="$image_link != 0">
    <meta property="og:title" content="{$prod_name}"/>
    <meta property="og:type" content="product"/>
    <meta property="og:image" content="{$image_link}"/>
    <meta property="og:description" content="{$FBDesc}"/>

    <meta property="og:price:amount" content="{$item_price}" />
    <meta property="og:upc" content="{$item_upc}" />
    <meta property="og:brand" content="{$item_brand}" />


    <meta property="og:price:currency" content="USD" />
    <meta property="og:availability" content="instock" />
    <link rel="image_src" href="{$image_link}" />

    </xsl:when>
    <xsl:otherwise></xsl:otherwise>
    </xsl:choose>

    </xsl:template>
    </xsl:stylesheet>
    </PackageTransform>
    </package>

  2. #2
    mmcgeachy is offline Senior Member
    Join Date
    Sep 2008
    Posts
    174

    Default

    Are the UPC and Brand columns you added to the database? Or are you using the extension data to store this information? Reason being is just looks like you need to edit your query to have a few more columns in the select statment. If it is columns then the edit the query to be something like this:

    Code:
    <query name="Products" rowElementName="Product">
    <sql>
    <![CDATA[
    SELECT p.ProductID, p.Name, p.SEDescription, p.ImageFileNameOverride, p.SKU , pv.Price, p.UPC, p.Brand
    FROM Product 
    join productvariant pv on p.ProductID = pv.ProductID
    WHERE p.ProductID = @ProductID
    ]]>
    </sql>
    <queryparam paramname="@ProductID" paramtype="request" requestparamname="ProductID" sqlDataType="int" defvalue="0" validationpattern="^\d{1,10}$" />
    </query>
    Also do keep in mind that a this will not work well on a with a product that has more then one variant.

  3. #3
    bashdaddy is offline Junior Member
    Join Date
    Jan 2010
    Posts
    6

    Default

    Thanks for the info so far.

    I'm not able to see the tables because the platform is managed by another company. It's my understanding that he SKU is a extension data field so I would assume the UPC and Brand is as well? Does that change what you gave me? I'm sorry but I very weak in this area of coding.

  4. #4
    mmcgeachy is offline Senior Member
    Join Date
    Sep 2008
    Posts
    174

    Default

    Well not being able to see the tables directly does make it quite a bit harder. However in this case you could still set debug on and then have a the query look something like this
    Code:
    <query name="Products" rowElementName="Product">
    <sql>
    <![CDATA[
    SELECT p.*, pv.*
    FROM Product 
    join productvariant pv on p.ProductID = pv.ProductID
    WHERE p.ProductID = @ProductID
    ]]>
    </sql>
    <queryparam paramname="@ProductID" paramtype="request" requestparamname="ProductID" sqlDataType="int" defvalue="0" validationpattern="^\d{1,10}$" />
    </query>
    That way you can see the values of all the columns in the xml run time results.

    Hope that helps