mivaecommerce / readytheme-shadows

Shadows is the development framework and methodology used for creating our ReadyThemes as well as custom websites.
https://shadows.mivareadythemes.com/
MIT License
4 stars 3 forks source link

PROD: Runtime error when no images are set for product #124

Closed influxweb closed 2 years ago

influxweb commented 2 years ago

Current Behavior

Shadows has modified the PROD page template to directly call Image_Load_ID without checking if the ProductImage_Load_Type call actually succeeded.

Correcting the Issue

To make the update, without applying the latest release, you will need to update the code in User Interface -> Templates -> Pages -> PROD:

<mvt:item name="html_profile"/>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <base href="&mvt:global:basehref;">
    <mvt:if expr="NOT ISNULL l.settings:product:page_title">
        <title>&mvt:product:page_title;</title>
    <mvt:elseif expr="NOT ISNULL l.settings:page:title">
        <title>&mvt:page:title;</title>
    <mvt:else>
        <title>&mvt:store:name;: &mvt:product:name;</title>
    </mvt:if>
    <mvt:item name="head" param="css_list" />
    <mvt:item name="head" param="head_tag" />
    <mvt:item name="attributemachine" param="head_deferred" />
    <mvt:item name="product_display_imagemachine" param="head_deferred" />
    <mvt:assign name="g.socialURL" value="l.settings:product:link" />
    <mvt:assign name="g.socialText" value="'Check out the deal on ' $ l.settings:product:name $ ' at ' $ g.store:name" />
    <mvt:do file="g.Module_Library_DB" name="l.image_count" value="ProductImageDataList_Load_Product(l.settings:product:id, l.settings:imagedata)" />
    <mvt:if expr="l.image_count GT 0">
        <mvt:assign name="g.socialImage" value="g.baseurl $ l.settings:imagedata[1]:image:image" />
    <mvt:else>
        <mvt:assign name="g.socialImage" value="g.baseurl $ 'graphics/en-US/admin/blank.gif'" />
    </mvt:if>
    <meta property="og:title" content="&mvte:product:name;">
    <meta property="og:type" content="product">
    <meta property="og:image" content="&mvt:global:socialImage;">
    <meta property="og:url" content="&mvt:global:socialURL;">
    <meta property="og:site_name" content="&mvte:global:store:name;">
    <meta property="og:description" content="&mvte:global:socialText;">
    <meta property="og:locale" content="en_US">
    <meta name="twitter:card" content="summary_large_image">
    <meta name="twitter:site" content="@TWITTER_ACCOUNT">
    <meta name="twitter:creator" content="@TWITTER_ACCOUNT">
    <meta name="twitter:url" content="&mvt:global:socialURL;">
    <meta name="twitter:title" content="&mvte:product:name;">
    <meta name="twitter:description" content="&mvte:global:socialText;">
    <meta name="twitter:image" content="&mvt:global:socialImage;">
    <meta name="twitter:image:alt" content="&mvte:product:name;">
</head>
<body id="js-&mvte:page:code;" class="o-site-wrapper t-page-&mvte:global:pageClass;">
    <mvt:item name="hdft" param="global_header" />

    <section class="o-layout">
        <div class="o-layout__item">
            <mvt:item name="hdft" param="header" />
        </div>
    </section>

    <section class="o-layout">
        <div class="o-layout__item">
            <mvt:item name="prod_ctgy_hdft" param="prod_header" />
        </div>
    </section>

    <!-- Start: Google Rich Snippets -->
    <mvt:comment>Strip any HTML from the product description.</mvt:comment>
    <mvt:assign name="l.settings:product:stripped_descrip" value="miva_html_strip(l.settings:product:descrip, '')"/>

    <div itemscope itemtype="http://schema.org/Product">
        <mvt:if expr="NOT ISNULL l.settings:product:sku">
            <meta itemprop="mpn" content="&mvte:product:sku;" />
            <meta itemprop="sku" content="&mvte:product:sku;" />
        <mvt:else>
            <meta itemprop="mpn" content="&mvte:product:code;" />
            <meta itemprop="sku" content="&mvte:product:code;" />
        </mvt:if>
        <meta itemprop="name" content="&mvte:product:name;" />
        <meta itemprop="image" content="&mvt:global:socialImage;" />
        <meta itemprop="category" content="&mvte:category:name;" />
        <meta itemprop="description" content="&mvte:product:stripped_descrip;" />
        <mvt:if expr="NOT ISNULL l.settings:product:customfield_values:customfields:brand">
            <meta itemprop="brand" content="&mvte:product:customfield_values:customfields:brand;" />
        <mvt:else>
            <meta itemprop="brand" content="&mvte:global:store:name;" />
        </mvt:if>
        <div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
            <meta itemprop="url" content="&mvte:product:link;" />
            <mvt:if expr="NOT ISNULL l.settings:product:sku">
                <meta itemprop="sku" content="&mvte:product:sku;" />
            <mvt:else>
                <meta itemprop="sku" content="&mvte:product:code;" />
            </mvt:if>
            <mvt:item name="product_display" />
            <mvt:item name="attributemachine" param="body_deferred" />
            <script>
                if (typeof am&mvt:product:id; !== 'undefined') {
                    let attrMachCall = am&mvt:product:id;;
                    let attrPossible = amPossible&mvt:product:id;;
                }
            </script>
            <meta itemprop="priceCurrency" content="USD" />
            <meta itemprop="seller" content="&mvte:global:store:name;" />
            <meta itemprop="itemCondition" content="new" />

            <mvt:if expr="l.settings:attributemachine:product:inv_level">
                <mvt:assign name="l.availability_inv_level" value="l.settings:attributemachine:product:inv_level"/>
                <mvt:do name="l.formatted_variant_price" file="g.Module_Root $ g.Store:currncy_mod:module" value="CurrencyModule_AddFormatting( g.Store:currncy_mod, l.settings:attributemachine:product:price )" />
                <meta itemprop="price" content="&mvt:attributemachine:product:price;"/>
            <mvt:else>
                <mvt:assign name="l.availability_inv_level" value="l.settings:product:inv_level"/>
                <meta itemprop="price" content="&mvt:product:price;"/>
            </mvt:if>
            <mvt:if expr="l.availability_inv_level EQ 'low'">
                <meta itemprop="availability" content="LimitedAvailability"/>
            <mvt:elseif expr="l.availability_inv_level EQ 'out'">
                <meta itemprop="availability" content="OutOfStock"/>
            <mvt:else>
                <meta itemprop="availability" content="InStock"/>
            </mvt:if>
        </div>
    </div>
    <!-- End: Google Rich Snippets -->

    <mvt:if expr="l.settings:related_product_count NE 0">
        <mvt:item name="related_products" />
    </mvt:if>

    <section class="o-layout">
        <div class="o-layout__item">
            <mvt:item name="prod_ctgy_hdft" param="prod_footer" />
        </div>
    </section>

    <section class="o-layout">
        <div class="o-layout__item">
            <mvt:item name="hdft" param="footer" />
        </div>
    </section>

    <mvt:item name="hdft" param="global_footer" />
</body>
</html>