Magento 2.2.5: Idea about delete “Banner_Slide” The Next CEO of Stack OverflowMagento 2.1: Do we need to do anything special for the controll action to accept HTTP Post with Json Payload?Magento 2: How to override newsletter Subscriber modelDI not working in ControllerMagento 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 FullText2 Different keys are being genereated, Admin Grid action column-> edit link and page created after clicking save and continue butottonMagento 2: I Want to add multiple product using checkboxMagento 2.2.5 - Delete all products and products images

What does "Its cash flow is deeply negative" mean?

Why do remote companies require working in the US?

When airplanes disconnect from a tanker during air to air refueling, why do they bank so sharply to the right?

% symbol leads to superlong (forever?) compilations

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

If I blow insulation everywhere in my attic except the door trap, will heat escape through it?

How to make a software documentation "officially" citable?

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

What is the difference between "behavior" and "behaviour"?

Science fiction (dystopian) short story set after WWIII

Why does standard notation not preserve intervals (visually)

Visit to the USA with ESTA approved before trip to Iran

Is HostGator storing my password in plaintext?

How to Reset Passwords on Multiple Websites Easily?

What's the point of interval inversion?

How to count occurrences of text in a file?

How do I construct this japanese bowl?

How do I solve this limit?

Was a professor correct to chastise me for writing "Prof. X" rather than "Professor X"?

How to start emacs in "nothing" mode (`fundamental-mode`)

If the heap is initialized for security, then why is the stack uninitialized?

Term for the "extreme-extension" version of a straw man fallacy?

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?

How should I support this large drywall patch?



Magento 2.2.5: Idea about delete “Banner_Slide”



The Next CEO of Stack OverflowMagento 2.1: Do we need to do anything special for the controll action to accept HTTP Post with Json Payload?Magento 2: How to override newsletter Subscriber modelDI not working in ControllerMagento 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 FullText2 Different keys are being genereated, Admin Grid action column-> edit link and page created after clicking save and continue butottonMagento 2: I Want to add multiple product using checkboxMagento 2.2.5 - Delete all products and products images










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

          How to solve knockout JS error in Magento 2 Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?(Magento2) knockout.js:3012 Uncaught ReferenceError: Unable to process bindingUnable to process binding Knockout.js magento 2Cannot read property `scopeLabel` of undefined on Product Detail PageCan't get Customer Data on frontend in Magento 2Magento2 Order Summary - unable to process bindingKO templates are not loading in Magento 2.1 applicationgetting knockout js error magento 2Product grid not load -— Unable to process binding Knockout.js magento 2Product form not loaded in magento2Uncaught ReferenceError: Unable to process binding “if: function()return (isShowLegend()) ” magento 2

          Nissan Patrol Зміст Перше покоління — 4W60 (1951-1960) | Друге покоління — 60 series (1960-1980) | Третє покоління (1980–2002) | Четверте покоління — Y60 (1987–1998) | П'яте покоління — Y61 (1997–2013) | Шосте покоління — Y62 (2010- ) | Посилання | Зноски | Навігаційне менюОфіційний український сайтТест-драйв Nissan Patrol 2010 7-го поколінняNissan PatrolКак мы тестировали Nissan Patrol 2016рвиправивши або дописавши її