1. Home
  2. Docs
  3. Drag and Drop Product Sorter for Bagisto
  4. Installation Process of the Extension
Download PDF

Installation Process of the Extension

1. Download the zip folder.

2. Unzip the folder and go to your Bagisto application path ‘packages’ and create a folder named ‘SunArc/DragDropProduct/’ upload ‘src’ folder inside this path.

3. Now open ‘config/app.php’ and register the DragDropProduct provider.

‘providers’ => [

        // Drag Drop Product provider

        SunArc\DragDropProduct\Providers\DragDropProductServiceProvider::class,

]

4. Now open composer.json and go to autoload psr-4.

“autoload”: {

        “psr-4”: {

        “SunArc\\DragDropProduct\\”: “packages/SunArc/DragDropProduct/src”

        }

    }

5. Now open the command prompt and run composer dump-autoload

6. Now run php artisan migrate

7. Now run php artisan config:cache

8.Now run php artisan optimize 

9.  php artisan vendor:publish –force

Once you enter this command it will show all provider list and trailing with their number as given in below screenshot.

In our case it’s DragDropProduct that contains number 18. Type 18 and enter, it will publish an extension icon and custom css.

10. Now go to your Bagisto admin section ‘admin/configuration/Drag Drop Product you will see the new Configuration setting. Please make it enabled.

10. Once enabled the Drag Drop Product module now you can see it in the backend admin panel like below. Just select the category and click on Manage Product Button.

Changes need to do in Frontend Part

  1. To see the option Sort By Position Wise frontend part first go to packages/Webkul/Product/src/Helpers/Toolbar.php and go to getAvailableOrders() method and add this line. ‘position-asc’ => ‘position-wise’  in existing Array.
  2. Now we need to add this option in our language file. For now I am adding it in the default English language. Go to packages/Webkul/Shop/src/Resources/lang/en/app.php where you will find a products array. Add a line in this array like below.

   It’s almost done. We are just 2 steps back to finish this setup. 

  1. Go to packages/Webkul/Product/src/Repositories/ProductRepository.php and search public function searchFromDatabase($categoryId). Add below code in two places.

->leftJoin(‘product_positions’, function ($join) use ($categoryId) {

    $join->on(‘products.id’, ‘=’, ‘product_positions.product_id’)

    ->where(‘product_positions.category_id’, $categoryId);

})

else if ($attribute->code === ‘position’) {

        $qb->orderBy(‘product_positions.id’, $sortOptions[‘order’]);

 }

  1. It’s the last but not the least step that we need to run this functionality. Go to the backend Admin/Catalog/Attributes page and add a new attribute that shows in the screenshot below. Make sure it will be the same as given in the screenshot. 

Note: If changes are not reflecting then please run below command again to see changes.

run php artisan optimize.

Download Guide
Was this article helpful to you? Yes No

How can we help?