Skip to main content

Reference Link

In module.xml add this :-

<sequence>
   <module name="Magento_Catalog"/> 
   <module name="Magento_CatalogSearch"/>         
   <module name="Magento_Checkout"/>
   <module name="Magento_Sales"/>
   <module name="Magento_Quote"/>
   <module name="Magento_Vault"/>
   <module name="Magento_OfflineShipping"/>           
</sequence> 

Or you Can Use Plugin For Override addUrlRewrite function

put below code in Namespace/Module/etc/di.xml

<type name="Magento\Catalog\Model\ResourceModel\Product\Collection">
    <plugin name="product-collection-addurlrewrite" type="Namespace\Module\Plugin\Product\Collection" sortOrder="1"/>
</type>

Create Namespace\Module\Plugin\Product\Collection.php and pasted below code in your file:

<?php
namespace Namespace\Module\Plugin\Product;

class Collection
{

    public function (typeofplugin(after,before,around))addUrlRewrite(\Magento\Catalog\Model\ResourceModel\Product\Collection $subject)
    {
         // do your stuff here
        return $result;
    }
}

Reference Link

In module.xml add this :-

<sequence>
   <module name="Magento_Catalog"/> 
   <module name="Magento_CatalogSearch"/>         
   <module name="Magento_Checkout"/>
   <module name="Magento_Sales"/>
   <module name="Magento_Quote"/>
   <module name="Magento_Vault"/>
   <module name="Magento_OfflineShipping"/>           
</sequence> 

Or you Can Use Plugin For Override addUrlRewrite function

put below code in Namespace/Module/etc/di.xml

<type name="Magento\Catalog\Model\ResourceModel\Product\Collection">
    <plugin name="product-collection-addurlrewrite" type="Namespace\Module\Plugin\Product\Collection" sortOrder="1"/>
</type>

Create Namespace\Module\Plugin\Product\Collection.php and pasted below code in your file:

<?php
namespace Namespace\Module\Plugin\Product;

class Collection
{

    public function addUrlRewrite()
    {
         // do your stuff here
        return $result;
    }
}

In module.xml add this :-

<sequence>
   <module name="Magento_Catalog"/> 
   <module name="Magento_CatalogSearch"/>         
   <module name="Magento_Checkout"/>
   <module name="Magento_Sales"/>
   <module name="Magento_Quote"/>
   <module name="Magento_Vault"/>
   <module name="Magento_OfflineShipping"/>           
</sequence> 

Or you Can Use Plugin For Override addUrlRewrite function

put below code in Namespace/Module/etc/di.xml

<type name="Magento\Catalog\Model\ResourceModel\Product\Collection">
    <plugin name="product-collection-addurlrewrite" type="Namespace\Module\Plugin\Product\Collection" sortOrder="1"/>
</type>

Create Namespace\Module\Plugin\Product\Collection.php and pasted below code in your file:

<?php
namespace Namespace\Module\Plugin\Product;

class Collection
{

    public function (typeofplugin(after,before,around))addUrlRewrite(\Magento\Catalog\Model\ResourceModel\Product\Collection $subject)
    {
         // do your stuff here
        return $result;
    }
}
added 438 characters in body
Source Link
Ronak Rathod
  • 6.5k
  • 18
  • 43

Reference Link

In Use plugin for thismodule.xml add this :-

<sequence>
   <module name="Magento_Catalog"/> 
   <module name="Magento_CatalogSearch"/>         
   <module name="Magento_Checkout"/>
   <module name="Magento_Sales"/>
   <module name="Magento_Quote"/>
   <module name="Magento_Vault"/>
   <module name="Magento_OfflineShipping"/>           
</sequence> 

Or you Can Use Plugin For Override addUrlRewrite function

put below code in Namespace/Module/etc/di.xml

<type name="Magento\Catalog\Model\ResourceModel\Product\Collection">
    <plugin name="product-collection-addurlrewrite" type="Namespace\Module\Plugin\Product\Collection" sortOrder="1"/>
</type>

Create Namespace\Module\Plugin\Product\Collection.php and pasted below code in your file:

<?php
namespace Namespace\Module\Plugin\Product;

class Collection
{

    public function addUrlRewrite()
    {
         // do your stuff here
        return $result;
    }
}

Use plugin for this

put below code in Namespace/Module/etc/di.xml

<type name="Magento\Catalog\Model\ResourceModel\Product\Collection">
    <plugin name="product-collection-addurlrewrite" type="Namespace\Module\Plugin\Product\Collection" sortOrder="1"/>
</type>

Create Namespace\Module\Plugin\Product\Collection.php and pasted below code in your file:

<?php
namespace Namespace\Module\Plugin\Product;

class Collection
{

    public function addUrlRewrite()
    {
         // do your stuff here
        return $result;
    }
}

Reference Link

In module.xml add this :-

<sequence>
   <module name="Magento_Catalog"/> 
   <module name="Magento_CatalogSearch"/>         
   <module name="Magento_Checkout"/>
   <module name="Magento_Sales"/>
   <module name="Magento_Quote"/>
   <module name="Magento_Vault"/>
   <module name="Magento_OfflineShipping"/>           
</sequence> 

Or you Can Use Plugin For Override addUrlRewrite function

put below code in Namespace/Module/etc/di.xml

<type name="Magento\Catalog\Model\ResourceModel\Product\Collection">
    <plugin name="product-collection-addurlrewrite" type="Namespace\Module\Plugin\Product\Collection" sortOrder="1"/>
</type>

Create Namespace\Module\Plugin\Product\Collection.php and pasted below code in your file:

<?php
namespace Namespace\Module\Plugin\Product;

class Collection
{

    public function addUrlRewrite()
    {
         // do your stuff here
        return $result;
    }
}
Source Link
Ronak Rathod
  • 6.5k
  • 18
  • 43

Use plugin for this

put below code in Namespace/Module/etc/di.xml

<type name="Magento\Catalog\Model\ResourceModel\Product\Collection">
    <plugin name="product-collection-addurlrewrite" type="Namespace\Module\Plugin\Product\Collection" sortOrder="1"/>
</type>

Create Namespace\Module\Plugin\Product\Collection.php and pasted below code in your file:

<?php
namespace Namespace\Module\Plugin\Product;

class Collection
{

    public function addUrlRewrite()
    {
         // do your stuff here
        return $result;
    }
}