Skip to content

Knockout Recently Viewed contains wrong product url (with category path), also not correct url <meta property="og:url"> on product view page #13227

@novakivskiy

Description

@novakivskiy

Preconditions

  1. Magento 2.2.2
  2. PHP 7

I added "Recently Viewed" to the product page. Using xml layout

 <referenceContainer name="content.aside">
            <block class="Magento\Catalog\Block\Widget\RecentlyViewed" name="recently_viewed" template="Magento_Catalog::product/widget/viewed/grid.phtml" after="-">
                <arguments>
                    <argument name="uiComponent" xsi:type="string">widget_recently_viewed</argument>
                    <argument name="page_size" xsi:type="number">4</argument>
                    <argument name="show_attributes" xsi:type="string">name,image,price</argument>
                    <argument name="show_buttons" xsi:type="string">add_to_cart,add_to_compare,add_to_wishlist</argument>
                </arguments>
            </block>
        </referenceContainer>

Steps to reproduce

  1. Site use product configuration "Use Categories Path for Product URLs" = NO
  2. Open several products to fill history of the products viewed
  3. On any page of the site, open page inspector(web developer utility) and see the local storage cache "product_data_storage", find product contain url with category path (http://take.ms/ukxAM).
    Or open source code html of product view page, and find the next code js component "Magento_Catalog/js/product/view/provider".

Example:

<script type="text/x-magento-init">
    {
        "*": {
                "Magento_Catalog/js/product/view/provider": {
                    "data": {"items":{"720" , ... {"url":"http:\/\/m2-sample.dev\/catalog\/product\/view\/id\/720\/s\/tiberius-gym-tank\/category\/13\/","id":720,"name":"Tiberius Gym Tank" ....    }
        }
    }
</script>

UPD:
Another way to proset the error:

  1. open product view page
  2. open source html page
  1. find tag <meta property="og:url" content="
  2. my result
    page url - http://m2-sample.dev/montana-wind-jacket.html, tag - <meta property="og:url" content="http://m2-sample.dev/men/tops-men/jackets-men/montana-wind-jacket.html" />

Expected result

  1. URL should not contain a category path (http://m2-sample.dev/tiberius-gym-tank.html)

Actual result

  1. image

Metadata

Metadata

Assignees

Labels

Event: dmcdindia1Fixed in 2.3.xThe issue has been fixed in 2.3 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releasegood first issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions