Magento 2.2.5: Idea about delete “Banner_Slide” The Next CEO of Stack OverflowMagento 2 “Recoverable Error: Argument 2 passed” when trying to define model in constructorMagento 2: How to override newsletter Subscriber modelMagento 2 HTTP error 500 on categories after compilationMagento 2: Delete duplicate products programaticallyMagento 2.2.5: How Search In Category Product Work?Magento 2.2.5: How to alter main_table before a columnMagento 2.2.5: Save and Continue Edit Button doesn't workMagento 2.2.5: About Search FullTextMagento 2.2.5: Explain about Position in “Catalog_Category_Product”Magento 2: I Want to add multiple product using checkbox

Which organization defines CJK Unified Ideographs?

Unreliable Magic - Is it worth it?

What makes a siege story/plot interesting?

Is it my responsibility to learn a new technology in my own time my employer wants to implement?

Too much space between section and text in a twocolumn document

Anatomically Correct Strange Women In Ponds Distributing Swords

How to safely derail a train during transit?

Why were Madagascar and New Zealand discovered so late?

Does the Brexit deal have to be agreed by both Houses?

Apart from "berlinern", do any other German dialects have a corresponding verb?

How do I construct this japanese bowl?

Would this house-rule that treats advantage as a +1 to the roll instead (and disadvantage as -1) and allows them to stack be balanced?

Whats the best way to handle refactoring a big file?

How to make a variable always equal to the result of some calculations?

Does it take more energy to get to Venus or to Mars?

Describing a person. What needs to be mentioned?

Why did we only see the N-1 starfighters in one film?

Go Pregnant or Go Home

Where to find order of arguments for default functions

Why does standard notation not preserve intervals (visually)

How can I get through very long and very dry, but also very useful technical documents when learning a new tool?

Can a single photon have an energy density?

Anatomically Correct Mesopelagic Aves

What is the purpose of the Evocation wizard's Potent Cantrip feature?



Magento 2.2.5: Idea about delete “Banner_Slide”



The Next CEO of Stack OverflowMagento 2 “Recoverable Error: Argument 2 passed” when trying to define model in constructorMagento 2: How to override newsletter Subscriber modelMagento 2 HTTP error 500 on categories after compilationMagento 2: Delete duplicate products programaticallyMagento 2.2.5: How Search In Category Product Work?Magento 2.2.5: How to alter main_table before a columnMagento 2.2.5: Save and Continue Edit Button doesn't workMagento 2.2.5: About Search FullTextMagento 2.2.5: Explain about Position in “Catalog_Category_Product”Magento 2: I Want to add multiple product using checkbox










3















i'm doing "Banner Slider" and looking for how to delete column in banner_slide. Its hard to explain. So just look in my example:



So this is what i've done til now. A banner which contain 3 slide.



enter image description here



What i want is when i click in that checkbox to turn off the choose, it will count and render through HTML and then when i click Save Banner or Save and Continue Edit, it will delete columns in banner_slide table in Mysql that have checkbox turning off.



So i'm following the catalog_category_products in magento 2. And what they do is look like this:
enter image description here
Like you can see, it render into HTML like i said.



And when i click on Save Banner button, it will run into Controller/../Save.php and save data to banner_slide table in Mysql.



So here is the Save.php:




C:xampphtdocsmagentoappcodeAhtBannerSliderControllerAdminhtmlManageSave.php




<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 20/07/2018
* Time: 4:15 CH
*/

namespace AhtBannerSliderControllerAdminhtmlManage;

use MagentoBackendAppActionContext;
use AhtBannerSliderModelBannerFactory;
use AhtBannerSliderModelBannerSlideFactory;

class Save extends MagentoFrameworkAppActionAction

protected $bannerFactory;

protected $bannerSlideFactory;

public function __construct(
Context $context,
BannerFactory $bannerFactory,
BannerSlideFactory $bannerSlideFactory
)
$this->bannerFactory = $bannerFactory;
$this->bannerSlideFactory = $bannerSlideFactory;

parent::__construct($context);

/**
* Save action
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @return MagentoFrameworkControllerResultInterface
*/
public function execute()

$data = $this->getRequest()->getPostValue();

/** @var MagentoBackendModelViewResultRedirect $resultRedirect */
$resultRedirect = $this->resultRedirectFactory->create();
//
if ($data)
try
$id = $this->getRequest()->getParam('id');

$banner = $this->bannerFactory->create();

if(isset($data['banner_slide']))
// lấy chuỗi json banner_slide được truyền vào từ form HTML.
$slide = json_decode($data['banner_slide'], true);
foreach($slide as $key => $value)
$bannerSlide = $this->bannerSlideFactory->create();

// check xem banner_slider này đã tồn tại hay chưa, nếu tồn tại thì không insert vào db.
$check = $bannerSlide->getCollection()
->addFieldToFilter('banner_id',$id)
->addFieldToFilter('slide_id',$key)
->getSize();
if($check = 0)
$bannerSlide->setBannerId($id);
$bannerSlide->setSlideId($key);
$bannerSlide->setPosition($value);
$bannerSlide->save();



if($id)
$banner->load($id);
$data['id'] = $id;

$banner->setData($data);
$banner->save();

if ($id)
$this->messageManager->addSuccessMessage(__('Update Banner Successfully.'));
else
$this->messageManager->addSuccessMessage(__('Add Banner Successfully.'));


// check for Save and Continue Edit Button
if ($this->getRequest()->getParam('back'))
return $resultRedirect->setPath('*/*/detail', ['id' => $banner->getId(), '_current' => true]);
else
$resultRedirect->setPath('*/*/');


return $resultRedirect;

catch (Exception $e)
$this->messageManager->addErrorMessage($e->getMessage());









Here is my banner_slide table:
enter image description here


I can save into the database through foreach loop successfully the banner_slide which "checkbox" turning on, but i dont know how to do that with banner_slide which turning off. So i need an idea on how to do that...


Thanks for reading. Have a good day :)



EDIT 1:



So i've found 2 way to do this:



  1. Delete all the record in table and then insert again.

  2. Select all the record in table and compare with the json banner_slide, and what doesn't have in json will be delete.

But what if i have 1000 record in the table? So these 2 way are not really good.










share|improve this question




























    3















    i'm doing "Banner Slider" and looking for how to delete column in banner_slide. Its hard to explain. So just look in my example:



    So this is what i've done til now. A banner which contain 3 slide.



    enter image description here



    What i want is when i click in that checkbox to turn off the choose, it will count and render through HTML and then when i click Save Banner or Save and Continue Edit, it will delete columns in banner_slide table in Mysql that have checkbox turning off.



    So i'm following the catalog_category_products in magento 2. And what they do is look like this:
    enter image description here
    Like you can see, it render into HTML like i said.



    And when i click on Save Banner button, it will run into Controller/../Save.php and save data to banner_slide table in Mysql.



    So here is the Save.php:




    C:xampphtdocsmagentoappcodeAhtBannerSliderControllerAdminhtmlManageSave.php




    <?php
    /**
    * Created by PhpStorm.
    * User: Administrator
    * Date: 20/07/2018
    * Time: 4:15 CH
    */

    namespace AhtBannerSliderControllerAdminhtmlManage;

    use MagentoBackendAppActionContext;
    use AhtBannerSliderModelBannerFactory;
    use AhtBannerSliderModelBannerSlideFactory;

    class Save extends MagentoFrameworkAppActionAction

    protected $bannerFactory;

    protected $bannerSlideFactory;

    public function __construct(
    Context $context,
    BannerFactory $bannerFactory,
    BannerSlideFactory $bannerSlideFactory
    )
    $this->bannerFactory = $bannerFactory;
    $this->bannerSlideFactory = $bannerSlideFactory;

    parent::__construct($context);

    /**
    * Save action
    *
    * @SuppressWarnings(PHPMD.CyclomaticComplexity)
    * @return MagentoFrameworkControllerResultInterface
    */
    public function execute()

    $data = $this->getRequest()->getPostValue();

    /** @var MagentoBackendModelViewResultRedirect $resultRedirect */
    $resultRedirect = $this->resultRedirectFactory->create();
    //
    if ($data)
    try
    $id = $this->getRequest()->getParam('id');

    $banner = $this->bannerFactory->create();

    if(isset($data['banner_slide']))
    // lấy chuỗi json banner_slide được truyền vào từ form HTML.
    $slide = json_decode($data['banner_slide'], true);
    foreach($slide as $key => $value)
    $bannerSlide = $this->bannerSlideFactory->create();

    // check xem banner_slider này đã tồn tại hay chưa, nếu tồn tại thì không insert vào db.
    $check = $bannerSlide->getCollection()
    ->addFieldToFilter('banner_id',$id)
    ->addFieldToFilter('slide_id',$key)
    ->getSize();
    if($check = 0)
    $bannerSlide->setBannerId($id);
    $bannerSlide->setSlideId($key);
    $bannerSlide->setPosition($value);
    $bannerSlide->save();



    if($id)
    $banner->load($id);
    $data['id'] = $id;

    $banner->setData($data);
    $banner->save();

    if ($id)
    $this->messageManager->addSuccessMessage(__('Update Banner Successfully.'));
    else
    $this->messageManager->addSuccessMessage(__('Add Banner Successfully.'));


    // check for Save and Continue Edit Button
    if ($this->getRequest()->getParam('back'))
    return $resultRedirect->setPath('*/*/detail', ['id' => $banner->getId(), '_current' => true]);
    else
    $resultRedirect->setPath('*/*/');


    return $resultRedirect;

    catch (Exception $e)
    $this->messageManager->addErrorMessage($e->getMessage());









    Here is my banner_slide table:
    enter image description here


    I can save into the database through foreach loop successfully the banner_slide which "checkbox" turning on, but i dont know how to do that with banner_slide which turning off. So i need an idea on how to do that...


    Thanks for reading. Have a good day :)



    EDIT 1:



    So i've found 2 way to do this:



    1. Delete all the record in table and then insert again.

    2. Select all the record in table and compare with the json banner_slide, and what doesn't have in json will be delete.

    But what if i have 1000 record in the table? So these 2 way are not really good.










    share|improve this question


























      3












      3








      3








      i'm doing "Banner Slider" and looking for how to delete column in banner_slide. Its hard to explain. So just look in my example:



      So this is what i've done til now. A banner which contain 3 slide.



      enter image description here



      What i want is when i click in that checkbox to turn off the choose, it will count and render through HTML and then when i click Save Banner or Save and Continue Edit, it will delete columns in banner_slide table in Mysql that have checkbox turning off.



      So i'm following the catalog_category_products in magento 2. And what they do is look like this:
      enter image description here
      Like you can see, it render into HTML like i said.



      And when i click on Save Banner button, it will run into Controller/../Save.php and save data to banner_slide table in Mysql.



      So here is the Save.php:




      C:xampphtdocsmagentoappcodeAhtBannerSliderControllerAdminhtmlManageSave.php




      <?php
      /**
      * Created by PhpStorm.
      * User: Administrator
      * Date: 20/07/2018
      * Time: 4:15 CH
      */

      namespace AhtBannerSliderControllerAdminhtmlManage;

      use MagentoBackendAppActionContext;
      use AhtBannerSliderModelBannerFactory;
      use AhtBannerSliderModelBannerSlideFactory;

      class Save extends MagentoFrameworkAppActionAction

      protected $bannerFactory;

      protected $bannerSlideFactory;

      public function __construct(
      Context $context,
      BannerFactory $bannerFactory,
      BannerSlideFactory $bannerSlideFactory
      )
      $this->bannerFactory = $bannerFactory;
      $this->bannerSlideFactory = $bannerSlideFactory;

      parent::__construct($context);

      /**
      * Save action
      *
      * @SuppressWarnings(PHPMD.CyclomaticComplexity)
      * @return MagentoFrameworkControllerResultInterface
      */
      public function execute()

      $data = $this->getRequest()->getPostValue();

      /** @var MagentoBackendModelViewResultRedirect $resultRedirect */
      $resultRedirect = $this->resultRedirectFactory->create();
      //
      if ($data)
      try
      $id = $this->getRequest()->getParam('id');

      $banner = $this->bannerFactory->create();

      if(isset($data['banner_slide']))
      // lấy chuỗi json banner_slide được truyền vào từ form HTML.
      $slide = json_decode($data['banner_slide'], true);
      foreach($slide as $key => $value)
      $bannerSlide = $this->bannerSlideFactory->create();

      // check xem banner_slider này đã tồn tại hay chưa, nếu tồn tại thì không insert vào db.
      $check = $bannerSlide->getCollection()
      ->addFieldToFilter('banner_id',$id)
      ->addFieldToFilter('slide_id',$key)
      ->getSize();
      if($check = 0)
      $bannerSlide->setBannerId($id);
      $bannerSlide->setSlideId($key);
      $bannerSlide->setPosition($value);
      $bannerSlide->save();



      if($id)
      $banner->load($id);
      $data['id'] = $id;

      $banner->setData($data);
      $banner->save();

      if ($id)
      $this->messageManager->addSuccessMessage(__('Update Banner Successfully.'));
      else
      $this->messageManager->addSuccessMessage(__('Add Banner Successfully.'));


      // check for Save and Continue Edit Button
      if ($this->getRequest()->getParam('back'))
      return $resultRedirect->setPath('*/*/detail', ['id' => $banner->getId(), '_current' => true]);
      else
      $resultRedirect->setPath('*/*/');


      return $resultRedirect;

      catch (Exception $e)
      $this->messageManager->addErrorMessage($e->getMessage());









      Here is my banner_slide table:
      enter image description here


      I can save into the database through foreach loop successfully the banner_slide which "checkbox" turning on, but i dont know how to do that with banner_slide which turning off. So i need an idea on how to do that...


      Thanks for reading. Have a good day :)



      EDIT 1:



      So i've found 2 way to do this:



      1. Delete all the record in table and then insert again.

      2. Select all the record in table and compare with the json banner_slide, and what doesn't have in json will be delete.

      But what if i have 1000 record in the table? So these 2 way are not really good.










      share|improve this question
















      i'm doing "Banner Slider" and looking for how to delete column in banner_slide. Its hard to explain. So just look in my example:



      So this is what i've done til now. A banner which contain 3 slide.



      enter image description here



      What i want is when i click in that checkbox to turn off the choose, it will count and render through HTML and then when i click Save Banner or Save and Continue Edit, it will delete columns in banner_slide table in Mysql that have checkbox turning off.



      So i'm following the catalog_category_products in magento 2. And what they do is look like this:
      enter image description here
      Like you can see, it render into HTML like i said.



      And when i click on Save Banner button, it will run into Controller/../Save.php and save data to banner_slide table in Mysql.



      So here is the Save.php:




      C:xampphtdocsmagentoappcodeAhtBannerSliderControllerAdminhtmlManageSave.php




      <?php
      /**
      * Created by PhpStorm.
      * User: Administrator
      * Date: 20/07/2018
      * Time: 4:15 CH
      */

      namespace AhtBannerSliderControllerAdminhtmlManage;

      use MagentoBackendAppActionContext;
      use AhtBannerSliderModelBannerFactory;
      use AhtBannerSliderModelBannerSlideFactory;

      class Save extends MagentoFrameworkAppActionAction

      protected $bannerFactory;

      protected $bannerSlideFactory;

      public function __construct(
      Context $context,
      BannerFactory $bannerFactory,
      BannerSlideFactory $bannerSlideFactory
      )
      $this->bannerFactory = $bannerFactory;
      $this->bannerSlideFactory = $bannerSlideFactory;

      parent::__construct($context);

      /**
      * Save action
      *
      * @SuppressWarnings(PHPMD.CyclomaticComplexity)
      * @return MagentoFrameworkControllerResultInterface
      */
      public function execute()

      $data = $this->getRequest()->getPostValue();

      /** @var MagentoBackendModelViewResultRedirect $resultRedirect */
      $resultRedirect = $this->resultRedirectFactory->create();
      //
      if ($data)
      try
      $id = $this->getRequest()->getParam('id');

      $banner = $this->bannerFactory->create();

      if(isset($data['banner_slide']))
      // lấy chuỗi json banner_slide được truyền vào từ form HTML.
      $slide = json_decode($data['banner_slide'], true);
      foreach($slide as $key => $value)
      $bannerSlide = $this->bannerSlideFactory->create();

      // check xem banner_slider này đã tồn tại hay chưa, nếu tồn tại thì không insert vào db.
      $check = $bannerSlide->getCollection()
      ->addFieldToFilter('banner_id',$id)
      ->addFieldToFilter('slide_id',$key)
      ->getSize();
      if($check = 0)
      $bannerSlide->setBannerId($id);
      $bannerSlide->setSlideId($key);
      $bannerSlide->setPosition($value);
      $bannerSlide->save();



      if($id)
      $banner->load($id);
      $data['id'] = $id;

      $banner->setData($data);
      $banner->save();

      if ($id)
      $this->messageManager->addSuccessMessage(__('Update Banner Successfully.'));
      else
      $this->messageManager->addSuccessMessage(__('Add Banner Successfully.'));


      // check for Save and Continue Edit Button
      if ($this->getRequest()->getParam('back'))
      return $resultRedirect->setPath('*/*/detail', ['id' => $banner->getId(), '_current' => true]);
      else
      $resultRedirect->setPath('*/*/');


      return $resultRedirect;

      catch (Exception $e)
      $this->messageManager->addErrorMessage($e->getMessage());









      Here is my banner_slide table:
      enter image description here


      I can save into the database through foreach loop successfully the banner_slide which "checkbox" turning on, but i dont know how to do that with banner_slide which turning off. So i need an idea on how to do that...


      Thanks for reading. Have a good day :)



      EDIT 1:



      So i've found 2 way to do this:



      1. Delete all the record in table and then insert again.

      2. Select all the record in table and compare with the json banner_slide, and what doesn't have in json will be delete.

      But what if i have 1000 record in the table? So these 2 way are not really good.







      magento2 delete banner-slider






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 8 mins ago









      Teja Bhagavan Kollepara

      3,01241949




      3,01241949










      asked Aug 10 '18 at 14:50









      fudufudu

      42311




      42311




















          1 Answer
          1






          active

          oldest

          votes


















          2














          Add the below code to your Grid.php:



          protected function _prepareMassaction()

          $this->setMassactionIdField('id');
          $this->getMassactionBlock()->setFormFieldName('id');

          $this->getMassactionBlock()->addItem(
          'delete',
          array(
          'label' => __('Delete'),
          'url' => $this->getUrl('banner/*/massDelete'),
          'confirm' => __('Are you sure?')
          )
          );
          return $this;



          Also create Delete.php controller and the below code under your module like below path:




          app/code/Vendor/Banner/Controller/Adminhtml/Banner/Delete.php




          Code for Delete.php:



          <?php
          namespace VendorBannerControllerAdminhtmlBanner;

          class MassDelete extends MagentoBackendAppAction

          /**
          * @var MagentoFrameworkViewResultPageFactory
          */
          public function execute()


          $ids = $this->getRequest()->getParam('id');
          if (!is_array($ids)



          You need to change the Vendor and Module name according to your requirement.






          share|improve this answer























          • hold up, so where exactly this massActionDelete should render in HTML?

            – fudu
            Aug 10 '18 at 15:25











          • if it render a Delete Action button, so i dont need it, because what i want is click the checkbox and then click "Save" button .

            – fudu
            Aug 10 '18 at 15:26











          • Just above your grid.

            – Sukumar Gorai
            Aug 10 '18 at 15:26











          • Mass action will show as a dropdown. from there you can select delete option and submit then all the selected banners will be deleted.

            – Sukumar Gorai
            Aug 10 '18 at 15:27












          • Yes i can see that, but that's not what i'm looking for .. @@ The goal here is when i click "save" , then it will delete what doesn't turn on in the checkbox.

            – fudu
            Aug 10 '18 at 15:46











          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "479"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f237998%2fmagento-2-2-5-idea-about-delete-banner-slide%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          Add the below code to your Grid.php:



          protected function _prepareMassaction()

          $this->setMassactionIdField('id');
          $this->getMassactionBlock()->setFormFieldName('id');

          $this->getMassactionBlock()->addItem(
          'delete',
          array(
          'label' => __('Delete'),
          'url' => $this->getUrl('banner/*/massDelete'),
          'confirm' => __('Are you sure?')
          )
          );
          return $this;



          Also create Delete.php controller and the below code under your module like below path:




          app/code/Vendor/Banner/Controller/Adminhtml/Banner/Delete.php




          Code for Delete.php:



          <?php
          namespace VendorBannerControllerAdminhtmlBanner;

          class MassDelete extends MagentoBackendAppAction

          /**
          * @var MagentoFrameworkViewResultPageFactory
          */
          public function execute()


          $ids = $this->getRequest()->getParam('id');
          if (!is_array($ids)



          You need to change the Vendor and Module name according to your requirement.






          share|improve this answer























          • hold up, so where exactly this massActionDelete should render in HTML?

            – fudu
            Aug 10 '18 at 15:25











          • if it render a Delete Action button, so i dont need it, because what i want is click the checkbox and then click "Save" button .

            – fudu
            Aug 10 '18 at 15:26











          • Just above your grid.

            – Sukumar Gorai
            Aug 10 '18 at 15:26











          • Mass action will show as a dropdown. from there you can select delete option and submit then all the selected banners will be deleted.

            – Sukumar Gorai
            Aug 10 '18 at 15:27












          • Yes i can see that, but that's not what i'm looking for .. @@ The goal here is when i click "save" , then it will delete what doesn't turn on in the checkbox.

            – fudu
            Aug 10 '18 at 15:46















          2














          Add the below code to your Grid.php:



          protected function _prepareMassaction()

          $this->setMassactionIdField('id');
          $this->getMassactionBlock()->setFormFieldName('id');

          $this->getMassactionBlock()->addItem(
          'delete',
          array(
          'label' => __('Delete'),
          'url' => $this->getUrl('banner/*/massDelete'),
          'confirm' => __('Are you sure?')
          )
          );
          return $this;



          Also create Delete.php controller and the below code under your module like below path:




          app/code/Vendor/Banner/Controller/Adminhtml/Banner/Delete.php




          Code for Delete.php:



          <?php
          namespace VendorBannerControllerAdminhtmlBanner;

          class MassDelete extends MagentoBackendAppAction

          /**
          * @var MagentoFrameworkViewResultPageFactory
          */
          public function execute()


          $ids = $this->getRequest()->getParam('id');
          if (!is_array($ids)



          You need to change the Vendor and Module name according to your requirement.






          share|improve this answer























          • hold up, so where exactly this massActionDelete should render in HTML?

            – fudu
            Aug 10 '18 at 15:25











          • if it render a Delete Action button, so i dont need it, because what i want is click the checkbox and then click "Save" button .

            – fudu
            Aug 10 '18 at 15:26











          • Just above your grid.

            – Sukumar Gorai
            Aug 10 '18 at 15:26











          • Mass action will show as a dropdown. from there you can select delete option and submit then all the selected banners will be deleted.

            – Sukumar Gorai
            Aug 10 '18 at 15:27












          • Yes i can see that, but that's not what i'm looking for .. @@ The goal here is when i click "save" , then it will delete what doesn't turn on in the checkbox.

            – fudu
            Aug 10 '18 at 15:46













          2












          2








          2







          Add the below code to your Grid.php:



          protected function _prepareMassaction()

          $this->setMassactionIdField('id');
          $this->getMassactionBlock()->setFormFieldName('id');

          $this->getMassactionBlock()->addItem(
          'delete',
          array(
          'label' => __('Delete'),
          'url' => $this->getUrl('banner/*/massDelete'),
          'confirm' => __('Are you sure?')
          )
          );
          return $this;



          Also create Delete.php controller and the below code under your module like below path:




          app/code/Vendor/Banner/Controller/Adminhtml/Banner/Delete.php




          Code for Delete.php:



          <?php
          namespace VendorBannerControllerAdminhtmlBanner;

          class MassDelete extends MagentoBackendAppAction

          /**
          * @var MagentoFrameworkViewResultPageFactory
          */
          public function execute()


          $ids = $this->getRequest()->getParam('id');
          if (!is_array($ids)



          You need to change the Vendor and Module name according to your requirement.






          share|improve this answer













          Add the below code to your Grid.php:



          protected function _prepareMassaction()

          $this->setMassactionIdField('id');
          $this->getMassactionBlock()->setFormFieldName('id');

          $this->getMassactionBlock()->addItem(
          'delete',
          array(
          'label' => __('Delete'),
          'url' => $this->getUrl('banner/*/massDelete'),
          'confirm' => __('Are you sure?')
          )
          );
          return $this;



          Also create Delete.php controller and the below code under your module like below path:




          app/code/Vendor/Banner/Controller/Adminhtml/Banner/Delete.php




          Code for Delete.php:



          <?php
          namespace VendorBannerControllerAdminhtmlBanner;

          class MassDelete extends MagentoBackendAppAction

          /**
          * @var MagentoFrameworkViewResultPageFactory
          */
          public function execute()


          $ids = $this->getRequest()->getParam('id');
          if (!is_array($ids)



          You need to change the Vendor and Module name according to your requirement.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Aug 10 '18 at 15:14









          Sukumar GoraiSukumar Gorai

          6,9303729




          6,9303729












          • hold up, so where exactly this massActionDelete should render in HTML?

            – fudu
            Aug 10 '18 at 15:25











          • if it render a Delete Action button, so i dont need it, because what i want is click the checkbox and then click "Save" button .

            – fudu
            Aug 10 '18 at 15:26











          • Just above your grid.

            – Sukumar Gorai
            Aug 10 '18 at 15:26











          • Mass action will show as a dropdown. from there you can select delete option and submit then all the selected banners will be deleted.

            – Sukumar Gorai
            Aug 10 '18 at 15:27












          • Yes i can see that, but that's not what i'm looking for .. @@ The goal here is when i click "save" , then it will delete what doesn't turn on in the checkbox.

            – fudu
            Aug 10 '18 at 15:46

















          • hold up, so where exactly this massActionDelete should render in HTML?

            – fudu
            Aug 10 '18 at 15:25











          • if it render a Delete Action button, so i dont need it, because what i want is click the checkbox and then click "Save" button .

            – fudu
            Aug 10 '18 at 15:26











          • Just above your grid.

            – Sukumar Gorai
            Aug 10 '18 at 15:26











          • Mass action will show as a dropdown. from there you can select delete option and submit then all the selected banners will be deleted.

            – Sukumar Gorai
            Aug 10 '18 at 15:27












          • Yes i can see that, but that's not what i'm looking for .. @@ The goal here is when i click "save" , then it will delete what doesn't turn on in the checkbox.

            – fudu
            Aug 10 '18 at 15:46
















          hold up, so where exactly this massActionDelete should render in HTML?

          – fudu
          Aug 10 '18 at 15:25





          hold up, so where exactly this massActionDelete should render in HTML?

          – fudu
          Aug 10 '18 at 15:25













          if it render a Delete Action button, so i dont need it, because what i want is click the checkbox and then click "Save" button .

          – fudu
          Aug 10 '18 at 15:26





          if it render a Delete Action button, so i dont need it, because what i want is click the checkbox and then click "Save" button .

          – fudu
          Aug 10 '18 at 15:26













          Just above your grid.

          – Sukumar Gorai
          Aug 10 '18 at 15:26





          Just above your grid.

          – Sukumar Gorai
          Aug 10 '18 at 15:26













          Mass action will show as a dropdown. from there you can select delete option and submit then all the selected banners will be deleted.

          – Sukumar Gorai
          Aug 10 '18 at 15:27






          Mass action will show as a dropdown. from there you can select delete option and submit then all the selected banners will be deleted.

          – Sukumar Gorai
          Aug 10 '18 at 15:27














          Yes i can see that, but that's not what i'm looking for .. @@ The goal here is when i click "save" , then it will delete what doesn't turn on in the checkbox.

          – fudu
          Aug 10 '18 at 15:46





          Yes i can see that, but that's not what i'm looking for .. @@ The goal here is when i click "save" , then it will delete what doesn't turn on in the checkbox.

          – fudu
          Aug 10 '18 at 15:46

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Magento Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f237998%2fmagento-2-2-5-idea-about-delete-banner-slide%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Can not update quote_id field of “quote_item” table magento 2Magento 2.1 - We can't remove the item. (Shopping Cart doesnt allow us to remove items before becomes empty)Add value for custom quote item attribute using REST apiREST API endpoint v1/carts/cartId/items always returns error messageCorrect way to save entries to databaseHow to remove all associated quote objects of a customer completelyMagento 2 - Save value from custom input field to quote_itemGet quote_item data using quote id and product id filter in Magento 2How to set additional data to quote_item table from controller in Magento 2?What is the purpose of additional_data column in quote_item table in magento2Set Custom Price to Quote item magento2 from controller

          Magento 2 disable Secret Key on URL's from terminal The Next CEO of Stack OverflowMagento 2 Shortcut/GUI tool to perform commandline tasks for windowsIn menu add configuration linkMagento oAuth : Generating access token and access secretMagento 2 security key issue in Third-Party API redirect URIPublic actions in admin controllersHow to Disable Cache in Custom WidgetURL Key not changing in Magento 2Product URL Key gets deleted when importing custom options - Magento 2Problem with reindex terminalMagento 2 - bin/magento Commands not working in Cpanel Terminal

          Aasi (pallopeli) Navigointivalikko