How to update record using multiple conditions in CollectionFactory magento 2 The 2019 Stack Overflow Developer Survey Results Are InUnit Test for overwrite collection class in magento2main.CRITICAL: Plugin class doesn't existHow to change save path of PDF files in magento 2Magento 2: How to override newsletter Subscriber modelMagento 2.1 Create a filter in the product grid by new attributeHow to override _registerJsPrice($price) function in Configurable.php Block in Magento2?Magento offline custom Payment method with drop down listMagento 2 Create dynamic array From different Model Collection to use in multi select in gridMagento 2: I Want to add multiple product using checkboxMagento 2.3 Can't view module's front end page output?

Is it correct to say the Neural Networks are an alternative way of performing Maximum Likelihood Estimation? if not, why?

What is the meaning of Triage in Cybersec world?

Is it ok to offer lower paid work as a trial period before negotiating for a full-time job?

Likelihood that a superbug or lethal virus could come from a landfill

How can I add encounters in the Lost Mine of Phandelver campaign without giving PCs too much XP?

Are there any other methods to apply to solving simultaneous equations?

Did Scotland spend $250,000 for the slogan "Welcome to Scotland"?

Deal with toxic manager when you can't quit

What do hard-Brexiteers want with respect to the Irish border?

Why can't devices on different VLANs, but on the same subnet, communicate?

Falsification in Math vs Science

How to translate "being like"?

Old scifi movie from the 50s or 60s with men in solid red uniforms who interrogate a spy from the past

Why didn't the Event Horizon Telescope team mention Sagittarius A*?

Are spiders unable to hurt humans, especially very small spiders?

Ubuntu Server install with full GUI

Is bread bad for ducks?

Is it ethical to upload a automatically generated paper to a non peer-reviewed site as part of a larger research?

"as much details as you can remember"

Why doesn't shell automatically fix "useless use of cat"?

Why not take a picture of a closer black hole?

A word that means fill it to the required quantity

Output the Arecibo Message

How to support a colleague who finds meetings extremely tiring?



How to update record using multiple conditions in CollectionFactory magento 2



The 2019 Stack Overflow Developer Survey Results Are InUnit Test for overwrite collection class in magento2main.CRITICAL: Plugin class doesn't existHow to change save path of PDF files in magento 2Magento 2: How to override newsletter Subscriber modelMagento 2.1 Create a filter in the product grid by new attributeHow to override _registerJsPrice($price) function in Configurable.php Block in Magento2?Magento offline custom Payment method with drop down listMagento 2 Create dynamic array From different Model Collection to use in multi select in gridMagento 2: I Want to add multiple product using checkboxMagento 2.3 Can't view module's front end page output?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I am trying to update the record but it creates a new record.



Collection factory



 <?php


namespace WebkulMpquotesystemBlock;

use WebkulMpquotesystemModelResourceModelQuoteconversation;
use MagentoFrameworkPricingHelperData;
use WebkulMpquotesystemModelQuotesFactory;
use WebkulMpquotesystemModelSellerQuotesFactory;
use WebkulMpquotesystemModelQuoteconversationFactory;
use MagentoCatalogModelProductFactory;
use WebkulMpquotesystemModelResourceModelSellerQuotes;


class Mpeditquotes extends MagentoFrameworkViewElementTemplate

/**
* @var customerSession
*/
protected $_customerSession;
/**
* @var MagentoCustomerModelCustomer
*/
protected $_customerModel;
/**
* @var quoteCollection
*/
protected $_quoteConversationCollection;
/**
* @var pricingHelper
*/
protected $_pricingHelper;
/**
* @var _quotesFactory
*/
protected $_quotesFactory;
/**
* @var _sellerQuoteFactory
*/
protected $_sellerQuoteFactory;
/**
* @var _productFactory
*/
protected $_productFactory;
/**
* @var MagentoCatalogHelperImage
*/
protected $_imageHelper;
/**
* @var _quoteConversationCollectionFactory
*/
protected $_quoteConversationCollectionFactory;
/**
* @var _quoteconversationFactory
*/
protected $_quoteconversationFactory;
protected $_sellercolletcionquotes;

/**
* @param MagentoCustomerModelSession $customerSession
* @param MagentoCustomerModelCustomer $customerModel
* @param MagentoCatalogBlockProductContext $context
* @param QuoteconversationCollectionFactory $conversationCollectionFactory
* @param QuotesFactory $_quotesFactory
* @param ProductFactory $productFactory
* @param QuoteconversationFactory $conversationFactory
* @param Data $pricingHelper
* @param array $data
*/

public function __construct(
MagentoCustomerModelSession $customerSession,
MagentoCustomerModelCustomer $customerModel,
MagentoCatalogBlockProductContext $context,
QuoteconversationCollectionFactory $conversationCollectionFactory,
QuotesFactory $_quotesFactory,
SellerQuotesFactory $sellerQuoteFactory,
ProductFactory $productFactory,
QuoteconversationFactory $conversationFactory,
WebkulMpquotesystemModelResourceModelSellerQuotesCollectionFactory $sellercolletcionquotes,
Data $pricingHelper,
array $data = []
)
$this->_customerSession = $customerSession;
$this->_customerModel = $customerModel;
$this->_quoteConversationCollectionFactory = $conversationCollectionFactory;
$this->_pricingHelper = $pricingHelper;
$this->_quotesFactory = $_quotesFactory;
$this->_productFactory = $productFactory;
$this->_sellerQuoteFactory = $sellerQuoteFactory;
$this->_quoteconversationFactory = $conversationFactory;
$this->_imageHelper = $context->getImageHelper();
$this->_sellercolletcionquotes = $sellercolletcionquotes;
parent::__construct($context, $data);

/**
* @return $this
*/
protected function _prepareLayout()

parent::_prepareLayout();
if ($this->getQuoteConversationCollection())
$pager = $this->getLayout()->createBlock(
'MagentoThemeBlockHtmlPager',
'mpquotesystem.pager'
)
->setCollection(
$this->getQuoteConversationCollection()
);
$this->setChild('pager', $pager);
$this->getQuoteConversationCollection()->load();


return $this;

/**
* @return string
*/
public function getPagerHtml()

return $this->getChildHtml('pager');

/**
* customer Id by customer session.
*
* @return int
*/
public function getCustomerId()

return $this->_customerSession->getCustomerId();

/**
* customer data by customer id.
*
* @return object
*/
public function getCustomerData($customerId)

return $this->_customerModel->load($customerId);

/**
* get Collection of quotes conversation for particular quote id.
*
* @return collection
*/
public function getQuoteConversationCollection()

if (!$this->_quoteConversationCollection)
$sellerquoteId = $this->getRequest()->getParam('id');
$sellerquote = $this->getSellerQuotes($sellerquoteId);
$quoteId = $sellerquote->getQuoteId();
$sellerId = $sellerquote->getSellerId();
if ($quoteId != 0)
$collection = $this->_quoteConversationCollectionFactory
->create()
->addFieldToFilter('quote_id', $quoteId)
->addFieldToFilter('sender', $sellerId);

$this->_quoteConversationCollection = $collection;



return $this->_quoteConversationCollection;

/**
* get formatted price by currency.
*
* @return format price string
*/
public function getFormattedPrice($price)

return $this->_pricingHelper
->currency($price, true, false);


public function getQuoteData($entityId)

$quoteModel = $this->_quotesFactory->create()->load($entityId);
return $quoteModel;

/**
* get Collection of quotes conversation for particular quote id.
*
* @return collection
*/
public function getsellerQuoteConversationCollection($quoteId)


if (!$this->_quoteConversationCollection)
//~ $quoteId = $this->getRequest()->getParam('id');
if ($quoteId != 0)
$collection = $this->_quoteConversationCollectionFactory
->create()
->addFieldToFilter('quote_id', $quoteId);

$this->_quoteConversationCollection = $collection;



return $this->_quoteConversationCollection;



/** public function **getsellerupdateCollection**($quoteId,$sellerid)



//~ $quoteId = $this->getRequest()->getParam('id');
if ($quoteId != 0)
$collection = $this->_sellercolletcionquotes
->create()

->load('quote_id',$quoteId)
->load('main_table.status',array('in'=>array('1','2')))
->load('main_table.seller_id',['neq'=>$sellerid])
->load('main_table.nstatus',1);

foreach($collection as $item)


$this->_sellercolletcionquotes = $collection;




return $this->_sellercolletcionquotes;
*/

public function getsellerupdateCollection($quoteId,$sellerid)



//~ $quoteId = $this->getRequest()->getParam('id');
if ($quoteId != 0)
$collection = $this->_sellercolletcionquotes
->create()
->addFieldToSelect('quote_id', $quoteId)
->addFieldToFilter('main_table.status', array('in' => array('1', '2')))
->addFieldToFilter('main_table.seller_id', ['neq' => $sellerid])
->addFieldToFilter('main_table.nstatus', 1);



foreach($collection as $item)

$item->setNstatus('Sold');
$item->save();



$this->_sellercolletcionquotes = $collection;

return $this->_sellercolletcionquotes;



public function getSellerQuotes($entityId)
$quoteModel = $this->_sellerQuoteFactory->create()->load($entityId);
return $quoteModel;

public function getProductData($productId)

$productModel = $this->_productFactory->create()->load($productId);
return $productModel;

public function imageHelperObj()

return $this->_imageHelper;

public function getProductPriceHtml(
MagentoCatalogModelProduct $product,
$priceType = MagentoCatalogPricingPriceFinalPrice::PRICE_CODE,
$renderZone = MagentoFrameworkPricingRender::ZONE_ITEM_LIST,
array $arguments = []
)
if (!isset($arguments['zone']))
$arguments['zone'] = $renderZone;


/** @var MagentoFrameworkPricingRender $priceRender */
$priceRender = $this->getLayout()->getBlock('product.price.render.default');
$price = '';

if ($priceRender)
$price = $priceRender->render($priceType, $product, $arguments);

return $price;


public function getParameters()

return $this->getRequest()->getParams();



/**
* getIsSecure check is secure or not
* @return boolean
*/
public function getIsSecure()

return $this->getRequest()->isSecure();

/**
* check whether a quote is sold or not?
* @param int $quoteStatus
* @return boolean
*/
public function quoteStatusIsNotSold($quoteStatus)

if ($quoteStatus!=WebkulMpquotesystemModelQuotes::STATUS_SOLD)
return true;

return false;





I want multiple where a condition for update record in Magento 2











share|improve this question






























    1















    I am trying to update the record but it creates a new record.



    Collection factory



     <?php


    namespace WebkulMpquotesystemBlock;

    use WebkulMpquotesystemModelResourceModelQuoteconversation;
    use MagentoFrameworkPricingHelperData;
    use WebkulMpquotesystemModelQuotesFactory;
    use WebkulMpquotesystemModelSellerQuotesFactory;
    use WebkulMpquotesystemModelQuoteconversationFactory;
    use MagentoCatalogModelProductFactory;
    use WebkulMpquotesystemModelResourceModelSellerQuotes;


    class Mpeditquotes extends MagentoFrameworkViewElementTemplate

    /**
    * @var customerSession
    */
    protected $_customerSession;
    /**
    * @var MagentoCustomerModelCustomer
    */
    protected $_customerModel;
    /**
    * @var quoteCollection
    */
    protected $_quoteConversationCollection;
    /**
    * @var pricingHelper
    */
    protected $_pricingHelper;
    /**
    * @var _quotesFactory
    */
    protected $_quotesFactory;
    /**
    * @var _sellerQuoteFactory
    */
    protected $_sellerQuoteFactory;
    /**
    * @var _productFactory
    */
    protected $_productFactory;
    /**
    * @var MagentoCatalogHelperImage
    */
    protected $_imageHelper;
    /**
    * @var _quoteConversationCollectionFactory
    */
    protected $_quoteConversationCollectionFactory;
    /**
    * @var _quoteconversationFactory
    */
    protected $_quoteconversationFactory;
    protected $_sellercolletcionquotes;

    /**
    * @param MagentoCustomerModelSession $customerSession
    * @param MagentoCustomerModelCustomer $customerModel
    * @param MagentoCatalogBlockProductContext $context
    * @param QuoteconversationCollectionFactory $conversationCollectionFactory
    * @param QuotesFactory $_quotesFactory
    * @param ProductFactory $productFactory
    * @param QuoteconversationFactory $conversationFactory
    * @param Data $pricingHelper
    * @param array $data
    */

    public function __construct(
    MagentoCustomerModelSession $customerSession,
    MagentoCustomerModelCustomer $customerModel,
    MagentoCatalogBlockProductContext $context,
    QuoteconversationCollectionFactory $conversationCollectionFactory,
    QuotesFactory $_quotesFactory,
    SellerQuotesFactory $sellerQuoteFactory,
    ProductFactory $productFactory,
    QuoteconversationFactory $conversationFactory,
    WebkulMpquotesystemModelResourceModelSellerQuotesCollectionFactory $sellercolletcionquotes,
    Data $pricingHelper,
    array $data = []
    )
    $this->_customerSession = $customerSession;
    $this->_customerModel = $customerModel;
    $this->_quoteConversationCollectionFactory = $conversationCollectionFactory;
    $this->_pricingHelper = $pricingHelper;
    $this->_quotesFactory = $_quotesFactory;
    $this->_productFactory = $productFactory;
    $this->_sellerQuoteFactory = $sellerQuoteFactory;
    $this->_quoteconversationFactory = $conversationFactory;
    $this->_imageHelper = $context->getImageHelper();
    $this->_sellercolletcionquotes = $sellercolletcionquotes;
    parent::__construct($context, $data);

    /**
    * @return $this
    */
    protected function _prepareLayout()

    parent::_prepareLayout();
    if ($this->getQuoteConversationCollection())
    $pager = $this->getLayout()->createBlock(
    'MagentoThemeBlockHtmlPager',
    'mpquotesystem.pager'
    )
    ->setCollection(
    $this->getQuoteConversationCollection()
    );
    $this->setChild('pager', $pager);
    $this->getQuoteConversationCollection()->load();


    return $this;

    /**
    * @return string
    */
    public function getPagerHtml()

    return $this->getChildHtml('pager');

    /**
    * customer Id by customer session.
    *
    * @return int
    */
    public function getCustomerId()

    return $this->_customerSession->getCustomerId();

    /**
    * customer data by customer id.
    *
    * @return object
    */
    public function getCustomerData($customerId)

    return $this->_customerModel->load($customerId);

    /**
    * get Collection of quotes conversation for particular quote id.
    *
    * @return collection
    */
    public function getQuoteConversationCollection()

    if (!$this->_quoteConversationCollection)
    $sellerquoteId = $this->getRequest()->getParam('id');
    $sellerquote = $this->getSellerQuotes($sellerquoteId);
    $quoteId = $sellerquote->getQuoteId();
    $sellerId = $sellerquote->getSellerId();
    if ($quoteId != 0)
    $collection = $this->_quoteConversationCollectionFactory
    ->create()
    ->addFieldToFilter('quote_id', $quoteId)
    ->addFieldToFilter('sender', $sellerId);

    $this->_quoteConversationCollection = $collection;



    return $this->_quoteConversationCollection;

    /**
    * get formatted price by currency.
    *
    * @return format price string
    */
    public function getFormattedPrice($price)

    return $this->_pricingHelper
    ->currency($price, true, false);


    public function getQuoteData($entityId)

    $quoteModel = $this->_quotesFactory->create()->load($entityId);
    return $quoteModel;

    /**
    * get Collection of quotes conversation for particular quote id.
    *
    * @return collection
    */
    public function getsellerQuoteConversationCollection($quoteId)


    if (!$this->_quoteConversationCollection)
    //~ $quoteId = $this->getRequest()->getParam('id');
    if ($quoteId != 0)
    $collection = $this->_quoteConversationCollectionFactory
    ->create()
    ->addFieldToFilter('quote_id', $quoteId);

    $this->_quoteConversationCollection = $collection;



    return $this->_quoteConversationCollection;



    /** public function **getsellerupdateCollection**($quoteId,$sellerid)



    //~ $quoteId = $this->getRequest()->getParam('id');
    if ($quoteId != 0)
    $collection = $this->_sellercolletcionquotes
    ->create()

    ->load('quote_id',$quoteId)
    ->load('main_table.status',array('in'=>array('1','2')))
    ->load('main_table.seller_id',['neq'=>$sellerid])
    ->load('main_table.nstatus',1);

    foreach($collection as $item)


    $this->_sellercolletcionquotes = $collection;




    return $this->_sellercolletcionquotes;
    */

    public function getsellerupdateCollection($quoteId,$sellerid)



    //~ $quoteId = $this->getRequest()->getParam('id');
    if ($quoteId != 0)
    $collection = $this->_sellercolletcionquotes
    ->create()
    ->addFieldToSelect('quote_id', $quoteId)
    ->addFieldToFilter('main_table.status', array('in' => array('1', '2')))
    ->addFieldToFilter('main_table.seller_id', ['neq' => $sellerid])
    ->addFieldToFilter('main_table.nstatus', 1);



    foreach($collection as $item)

    $item->setNstatus('Sold');
    $item->save();



    $this->_sellercolletcionquotes = $collection;

    return $this->_sellercolletcionquotes;



    public function getSellerQuotes($entityId)
    $quoteModel = $this->_sellerQuoteFactory->create()->load($entityId);
    return $quoteModel;

    public function getProductData($productId)

    $productModel = $this->_productFactory->create()->load($productId);
    return $productModel;

    public function imageHelperObj()

    return $this->_imageHelper;

    public function getProductPriceHtml(
    MagentoCatalogModelProduct $product,
    $priceType = MagentoCatalogPricingPriceFinalPrice::PRICE_CODE,
    $renderZone = MagentoFrameworkPricingRender::ZONE_ITEM_LIST,
    array $arguments = []
    )
    if (!isset($arguments['zone']))
    $arguments['zone'] = $renderZone;


    /** @var MagentoFrameworkPricingRender $priceRender */
    $priceRender = $this->getLayout()->getBlock('product.price.render.default');
    $price = '';

    if ($priceRender)
    $price = $priceRender->render($priceType, $product, $arguments);

    return $price;


    public function getParameters()

    return $this->getRequest()->getParams();



    /**
    * getIsSecure check is secure or not
    * @return boolean
    */
    public function getIsSecure()

    return $this->getRequest()->isSecure();

    /**
    * check whether a quote is sold or not?
    * @param int $quoteStatus
    * @return boolean
    */
    public function quoteStatusIsNotSold($quoteStatus)

    if ($quoteStatus!=WebkulMpquotesystemModelQuotes::STATUS_SOLD)
    return true;

    return false;





    I want multiple where a condition for update record in Magento 2











    share|improve this question


























      1












      1








      1


      1






      I am trying to update the record but it creates a new record.



      Collection factory



       <?php


      namespace WebkulMpquotesystemBlock;

      use WebkulMpquotesystemModelResourceModelQuoteconversation;
      use MagentoFrameworkPricingHelperData;
      use WebkulMpquotesystemModelQuotesFactory;
      use WebkulMpquotesystemModelSellerQuotesFactory;
      use WebkulMpquotesystemModelQuoteconversationFactory;
      use MagentoCatalogModelProductFactory;
      use WebkulMpquotesystemModelResourceModelSellerQuotes;


      class Mpeditquotes extends MagentoFrameworkViewElementTemplate

      /**
      * @var customerSession
      */
      protected $_customerSession;
      /**
      * @var MagentoCustomerModelCustomer
      */
      protected $_customerModel;
      /**
      * @var quoteCollection
      */
      protected $_quoteConversationCollection;
      /**
      * @var pricingHelper
      */
      protected $_pricingHelper;
      /**
      * @var _quotesFactory
      */
      protected $_quotesFactory;
      /**
      * @var _sellerQuoteFactory
      */
      protected $_sellerQuoteFactory;
      /**
      * @var _productFactory
      */
      protected $_productFactory;
      /**
      * @var MagentoCatalogHelperImage
      */
      protected $_imageHelper;
      /**
      * @var _quoteConversationCollectionFactory
      */
      protected $_quoteConversationCollectionFactory;
      /**
      * @var _quoteconversationFactory
      */
      protected $_quoteconversationFactory;
      protected $_sellercolletcionquotes;

      /**
      * @param MagentoCustomerModelSession $customerSession
      * @param MagentoCustomerModelCustomer $customerModel
      * @param MagentoCatalogBlockProductContext $context
      * @param QuoteconversationCollectionFactory $conversationCollectionFactory
      * @param QuotesFactory $_quotesFactory
      * @param ProductFactory $productFactory
      * @param QuoteconversationFactory $conversationFactory
      * @param Data $pricingHelper
      * @param array $data
      */

      public function __construct(
      MagentoCustomerModelSession $customerSession,
      MagentoCustomerModelCustomer $customerModel,
      MagentoCatalogBlockProductContext $context,
      QuoteconversationCollectionFactory $conversationCollectionFactory,
      QuotesFactory $_quotesFactory,
      SellerQuotesFactory $sellerQuoteFactory,
      ProductFactory $productFactory,
      QuoteconversationFactory $conversationFactory,
      WebkulMpquotesystemModelResourceModelSellerQuotesCollectionFactory $sellercolletcionquotes,
      Data $pricingHelper,
      array $data = []
      )
      $this->_customerSession = $customerSession;
      $this->_customerModel = $customerModel;
      $this->_quoteConversationCollectionFactory = $conversationCollectionFactory;
      $this->_pricingHelper = $pricingHelper;
      $this->_quotesFactory = $_quotesFactory;
      $this->_productFactory = $productFactory;
      $this->_sellerQuoteFactory = $sellerQuoteFactory;
      $this->_quoteconversationFactory = $conversationFactory;
      $this->_imageHelper = $context->getImageHelper();
      $this->_sellercolletcionquotes = $sellercolletcionquotes;
      parent::__construct($context, $data);

      /**
      * @return $this
      */
      protected function _prepareLayout()

      parent::_prepareLayout();
      if ($this->getQuoteConversationCollection())
      $pager = $this->getLayout()->createBlock(
      'MagentoThemeBlockHtmlPager',
      'mpquotesystem.pager'
      )
      ->setCollection(
      $this->getQuoteConversationCollection()
      );
      $this->setChild('pager', $pager);
      $this->getQuoteConversationCollection()->load();


      return $this;

      /**
      * @return string
      */
      public function getPagerHtml()

      return $this->getChildHtml('pager');

      /**
      * customer Id by customer session.
      *
      * @return int
      */
      public function getCustomerId()

      return $this->_customerSession->getCustomerId();

      /**
      * customer data by customer id.
      *
      * @return object
      */
      public function getCustomerData($customerId)

      return $this->_customerModel->load($customerId);

      /**
      * get Collection of quotes conversation for particular quote id.
      *
      * @return collection
      */
      public function getQuoteConversationCollection()

      if (!$this->_quoteConversationCollection)
      $sellerquoteId = $this->getRequest()->getParam('id');
      $sellerquote = $this->getSellerQuotes($sellerquoteId);
      $quoteId = $sellerquote->getQuoteId();
      $sellerId = $sellerquote->getSellerId();
      if ($quoteId != 0)
      $collection = $this->_quoteConversationCollectionFactory
      ->create()
      ->addFieldToFilter('quote_id', $quoteId)
      ->addFieldToFilter('sender', $sellerId);

      $this->_quoteConversationCollection = $collection;



      return $this->_quoteConversationCollection;

      /**
      * get formatted price by currency.
      *
      * @return format price string
      */
      public function getFormattedPrice($price)

      return $this->_pricingHelper
      ->currency($price, true, false);


      public function getQuoteData($entityId)

      $quoteModel = $this->_quotesFactory->create()->load($entityId);
      return $quoteModel;

      /**
      * get Collection of quotes conversation for particular quote id.
      *
      * @return collection
      */
      public function getsellerQuoteConversationCollection($quoteId)


      if (!$this->_quoteConversationCollection)
      //~ $quoteId = $this->getRequest()->getParam('id');
      if ($quoteId != 0)
      $collection = $this->_quoteConversationCollectionFactory
      ->create()
      ->addFieldToFilter('quote_id', $quoteId);

      $this->_quoteConversationCollection = $collection;



      return $this->_quoteConversationCollection;



      /** public function **getsellerupdateCollection**($quoteId,$sellerid)



      //~ $quoteId = $this->getRequest()->getParam('id');
      if ($quoteId != 0)
      $collection = $this->_sellercolletcionquotes
      ->create()

      ->load('quote_id',$quoteId)
      ->load('main_table.status',array('in'=>array('1','2')))
      ->load('main_table.seller_id',['neq'=>$sellerid])
      ->load('main_table.nstatus',1);

      foreach($collection as $item)


      $this->_sellercolletcionquotes = $collection;




      return $this->_sellercolletcionquotes;
      */

      public function getsellerupdateCollection($quoteId,$sellerid)



      //~ $quoteId = $this->getRequest()->getParam('id');
      if ($quoteId != 0)
      $collection = $this->_sellercolletcionquotes
      ->create()
      ->addFieldToSelect('quote_id', $quoteId)
      ->addFieldToFilter('main_table.status', array('in' => array('1', '2')))
      ->addFieldToFilter('main_table.seller_id', ['neq' => $sellerid])
      ->addFieldToFilter('main_table.nstatus', 1);



      foreach($collection as $item)

      $item->setNstatus('Sold');
      $item->save();



      $this->_sellercolletcionquotes = $collection;

      return $this->_sellercolletcionquotes;



      public function getSellerQuotes($entityId)
      $quoteModel = $this->_sellerQuoteFactory->create()->load($entityId);
      return $quoteModel;

      public function getProductData($productId)

      $productModel = $this->_productFactory->create()->load($productId);
      return $productModel;

      public function imageHelperObj()

      return $this->_imageHelper;

      public function getProductPriceHtml(
      MagentoCatalogModelProduct $product,
      $priceType = MagentoCatalogPricingPriceFinalPrice::PRICE_CODE,
      $renderZone = MagentoFrameworkPricingRender::ZONE_ITEM_LIST,
      array $arguments = []
      )
      if (!isset($arguments['zone']))
      $arguments['zone'] = $renderZone;


      /** @var MagentoFrameworkPricingRender $priceRender */
      $priceRender = $this->getLayout()->getBlock('product.price.render.default');
      $price = '';

      if ($priceRender)
      $price = $priceRender->render($priceType, $product, $arguments);

      return $price;


      public function getParameters()

      return $this->getRequest()->getParams();



      /**
      * getIsSecure check is secure or not
      * @return boolean
      */
      public function getIsSecure()

      return $this->getRequest()->isSecure();

      /**
      * check whether a quote is sold or not?
      * @param int $quoteStatus
      * @return boolean
      */
      public function quoteStatusIsNotSold($quoteStatus)

      if ($quoteStatus!=WebkulMpquotesystemModelQuotes::STATUS_SOLD)
      return true;

      return false;





      I want multiple where a condition for update record in Magento 2











      share|improve this question
















      I am trying to update the record but it creates a new record.



      Collection factory



       <?php


      namespace WebkulMpquotesystemBlock;

      use WebkulMpquotesystemModelResourceModelQuoteconversation;
      use MagentoFrameworkPricingHelperData;
      use WebkulMpquotesystemModelQuotesFactory;
      use WebkulMpquotesystemModelSellerQuotesFactory;
      use WebkulMpquotesystemModelQuoteconversationFactory;
      use MagentoCatalogModelProductFactory;
      use WebkulMpquotesystemModelResourceModelSellerQuotes;


      class Mpeditquotes extends MagentoFrameworkViewElementTemplate

      /**
      * @var customerSession
      */
      protected $_customerSession;
      /**
      * @var MagentoCustomerModelCustomer
      */
      protected $_customerModel;
      /**
      * @var quoteCollection
      */
      protected $_quoteConversationCollection;
      /**
      * @var pricingHelper
      */
      protected $_pricingHelper;
      /**
      * @var _quotesFactory
      */
      protected $_quotesFactory;
      /**
      * @var _sellerQuoteFactory
      */
      protected $_sellerQuoteFactory;
      /**
      * @var _productFactory
      */
      protected $_productFactory;
      /**
      * @var MagentoCatalogHelperImage
      */
      protected $_imageHelper;
      /**
      * @var _quoteConversationCollectionFactory
      */
      protected $_quoteConversationCollectionFactory;
      /**
      * @var _quoteconversationFactory
      */
      protected $_quoteconversationFactory;
      protected $_sellercolletcionquotes;

      /**
      * @param MagentoCustomerModelSession $customerSession
      * @param MagentoCustomerModelCustomer $customerModel
      * @param MagentoCatalogBlockProductContext $context
      * @param QuoteconversationCollectionFactory $conversationCollectionFactory
      * @param QuotesFactory $_quotesFactory
      * @param ProductFactory $productFactory
      * @param QuoteconversationFactory $conversationFactory
      * @param Data $pricingHelper
      * @param array $data
      */

      public function __construct(
      MagentoCustomerModelSession $customerSession,
      MagentoCustomerModelCustomer $customerModel,
      MagentoCatalogBlockProductContext $context,
      QuoteconversationCollectionFactory $conversationCollectionFactory,
      QuotesFactory $_quotesFactory,
      SellerQuotesFactory $sellerQuoteFactory,
      ProductFactory $productFactory,
      QuoteconversationFactory $conversationFactory,
      WebkulMpquotesystemModelResourceModelSellerQuotesCollectionFactory $sellercolletcionquotes,
      Data $pricingHelper,
      array $data = []
      )
      $this->_customerSession = $customerSession;
      $this->_customerModel = $customerModel;
      $this->_quoteConversationCollectionFactory = $conversationCollectionFactory;
      $this->_pricingHelper = $pricingHelper;
      $this->_quotesFactory = $_quotesFactory;
      $this->_productFactory = $productFactory;
      $this->_sellerQuoteFactory = $sellerQuoteFactory;
      $this->_quoteconversationFactory = $conversationFactory;
      $this->_imageHelper = $context->getImageHelper();
      $this->_sellercolletcionquotes = $sellercolletcionquotes;
      parent::__construct($context, $data);

      /**
      * @return $this
      */
      protected function _prepareLayout()

      parent::_prepareLayout();
      if ($this->getQuoteConversationCollection())
      $pager = $this->getLayout()->createBlock(
      'MagentoThemeBlockHtmlPager',
      'mpquotesystem.pager'
      )
      ->setCollection(
      $this->getQuoteConversationCollection()
      );
      $this->setChild('pager', $pager);
      $this->getQuoteConversationCollection()->load();


      return $this;

      /**
      * @return string
      */
      public function getPagerHtml()

      return $this->getChildHtml('pager');

      /**
      * customer Id by customer session.
      *
      * @return int
      */
      public function getCustomerId()

      return $this->_customerSession->getCustomerId();

      /**
      * customer data by customer id.
      *
      * @return object
      */
      public function getCustomerData($customerId)

      return $this->_customerModel->load($customerId);

      /**
      * get Collection of quotes conversation for particular quote id.
      *
      * @return collection
      */
      public function getQuoteConversationCollection()

      if (!$this->_quoteConversationCollection)
      $sellerquoteId = $this->getRequest()->getParam('id');
      $sellerquote = $this->getSellerQuotes($sellerquoteId);
      $quoteId = $sellerquote->getQuoteId();
      $sellerId = $sellerquote->getSellerId();
      if ($quoteId != 0)
      $collection = $this->_quoteConversationCollectionFactory
      ->create()
      ->addFieldToFilter('quote_id', $quoteId)
      ->addFieldToFilter('sender', $sellerId);

      $this->_quoteConversationCollection = $collection;



      return $this->_quoteConversationCollection;

      /**
      * get formatted price by currency.
      *
      * @return format price string
      */
      public function getFormattedPrice($price)

      return $this->_pricingHelper
      ->currency($price, true, false);


      public function getQuoteData($entityId)

      $quoteModel = $this->_quotesFactory->create()->load($entityId);
      return $quoteModel;

      /**
      * get Collection of quotes conversation for particular quote id.
      *
      * @return collection
      */
      public function getsellerQuoteConversationCollection($quoteId)


      if (!$this->_quoteConversationCollection)
      //~ $quoteId = $this->getRequest()->getParam('id');
      if ($quoteId != 0)
      $collection = $this->_quoteConversationCollectionFactory
      ->create()
      ->addFieldToFilter('quote_id', $quoteId);

      $this->_quoteConversationCollection = $collection;



      return $this->_quoteConversationCollection;



      /** public function **getsellerupdateCollection**($quoteId,$sellerid)



      //~ $quoteId = $this->getRequest()->getParam('id');
      if ($quoteId != 0)
      $collection = $this->_sellercolletcionquotes
      ->create()

      ->load('quote_id',$quoteId)
      ->load('main_table.status',array('in'=>array('1','2')))
      ->load('main_table.seller_id',['neq'=>$sellerid])
      ->load('main_table.nstatus',1);

      foreach($collection as $item)


      $this->_sellercolletcionquotes = $collection;




      return $this->_sellercolletcionquotes;
      */

      public function getsellerupdateCollection($quoteId,$sellerid)



      //~ $quoteId = $this->getRequest()->getParam('id');
      if ($quoteId != 0)
      $collection = $this->_sellercolletcionquotes
      ->create()
      ->addFieldToSelect('quote_id', $quoteId)
      ->addFieldToFilter('main_table.status', array('in' => array('1', '2')))
      ->addFieldToFilter('main_table.seller_id', ['neq' => $sellerid])
      ->addFieldToFilter('main_table.nstatus', 1);



      foreach($collection as $item)

      $item->setNstatus('Sold');
      $item->save();



      $this->_sellercolletcionquotes = $collection;

      return $this->_sellercolletcionquotes;



      public function getSellerQuotes($entityId)
      $quoteModel = $this->_sellerQuoteFactory->create()->load($entityId);
      return $quoteModel;

      public function getProductData($productId)

      $productModel = $this->_productFactory->create()->load($productId);
      return $productModel;

      public function imageHelperObj()

      return $this->_imageHelper;

      public function getProductPriceHtml(
      MagentoCatalogModelProduct $product,
      $priceType = MagentoCatalogPricingPriceFinalPrice::PRICE_CODE,
      $renderZone = MagentoFrameworkPricingRender::ZONE_ITEM_LIST,
      array $arguments = []
      )
      if (!isset($arguments['zone']))
      $arguments['zone'] = $renderZone;


      /** @var MagentoFrameworkPricingRender $priceRender */
      $priceRender = $this->getLayout()->getBlock('product.price.render.default');
      $price = '';

      if ($priceRender)
      $price = $priceRender->render($priceType, $product, $arguments);

      return $price;


      public function getParameters()

      return $this->getRequest()->getParams();



      /**
      * getIsSecure check is secure or not
      * @return boolean
      */
      public function getIsSecure()

      return $this->getRequest()->isSecure();

      /**
      * check whether a quote is sold or not?
      * @param int $quoteStatus
      * @return boolean
      */
      public function quoteStatusIsNotSold($quoteStatus)

      if ($quoteStatus!=WebkulMpquotesystemModelQuotes::STATUS_SOLD)
      return true;

      return false;





      I want multiple where a condition for update record in Magento 2








      magento2 collection quote resource-model factory






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Apr 8 at 12:28







      prabhakaran7

















      asked Apr 8 at 10:22









      prabhakaran7prabhakaran7

      32411




      32411




















          2 Answers
          2






          active

          oldest

          votes


















          0














          Try this one, adding getCollection():



          public function getsellerupdateCollection($quoteId,$sellerid)

          if ($quoteId != 0)
          $collection = $this->_sellercolletcionquotes
          ->create()->getCollection()
          ->addFieldToSelect('quote_id',$quoteId)
          ->addFieldToFilter('main_table.status',array('in'=>array('1','2')))
          ->addFieldToFilter('main_table.seller_id',['neq'=>$sellerid])
          ->addFieldToFilter('main_table.nstatus',1);

          foreach($collections as $item)

          $item->setNstatus('Sold');
          $item->save();

          $this->_sellercolletcionquotes = $collection;

          return $this->_sellercolletcionquotes;






          share|improve this answer

























          • where i can use save(); - method

            – prabhakaran7
            Apr 8 at 12:05











          • updated the answer

            – magefms
            Apr 8 at 12:06











          • Uncaught Error: Call to undefined method in Resource model Collection::getCollection() in /var/www/html/*

            – prabhakaran7
            Apr 8 at 12:07












          • i already defined in constract WebkulMpquotesystemModelResourceModelSellerQuotesCollectionFactory $sellercolletcionquotes,

            – prabhakaran7
            Apr 8 at 12:08






          • 1





            i make mistake ** ->addFieldToSelect('quote_id',$quoteId)** addFieldsToFIlter instead select

            – prabhakaran7
            yesterday


















          0














          I have updated a few lines of code.



          public function getsellerupdateCollection($quoteId,$sellerid)

          if ($quoteId != 0)
          $collection = $this->_sellercolletcionquotes
          ->create()->getCollection()
          ->addFieldToSelect('quote_id',$quoteId)
          ->addFieldToFilter('main_table.status',array('in'=>array('1','2')))
          ->addFieldToFilter('main_table.seller_id',['neq'=>$sellerid])
          ->addFieldToFilter('main_table.nstatus',1);

          foreach($collections as $item)

          $item->setNstatus('Sold');
          $item->save();

          $this->_sellercolletcionquotes = $collection;

          return $this->_sellercolletcionquotes;






          share|improve this answer

























          • i will check .....................

            – prabhakaran7
            Apr 8 at 11:46











          • Why you are adding condition like this ->addFieldToFilter('main_table.seller_id',['neq'=>$sellerid]) instead of ->addFieldToFilter('main_table.seller_id',['eq'=>$sellerid])

            – Kamlesh Solanki
            Apr 8 at 11:48











          • i am omitting that customer for update...

            – prabhakaran7
            Apr 8 at 11:50











          • ok is that worked?

            – Kamlesh Solanki
            Apr 8 at 11:54











          • Actaully, what you want update it

            – Kamlesh Solanki
            Apr 8 at 11:56











          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%2f269139%2fhow-to-update-record-using-multiple-conditions-in-collectionfactory-magento-2%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Try this one, adding getCollection():



          public function getsellerupdateCollection($quoteId,$sellerid)

          if ($quoteId != 0)
          $collection = $this->_sellercolletcionquotes
          ->create()->getCollection()
          ->addFieldToSelect('quote_id',$quoteId)
          ->addFieldToFilter('main_table.status',array('in'=>array('1','2')))
          ->addFieldToFilter('main_table.seller_id',['neq'=>$sellerid])
          ->addFieldToFilter('main_table.nstatus',1);

          foreach($collections as $item)

          $item->setNstatus('Sold');
          $item->save();

          $this->_sellercolletcionquotes = $collection;

          return $this->_sellercolletcionquotes;






          share|improve this answer

























          • where i can use save(); - method

            – prabhakaran7
            Apr 8 at 12:05











          • updated the answer

            – magefms
            Apr 8 at 12:06











          • Uncaught Error: Call to undefined method in Resource model Collection::getCollection() in /var/www/html/*

            – prabhakaran7
            Apr 8 at 12:07












          • i already defined in constract WebkulMpquotesystemModelResourceModelSellerQuotesCollectionFactory $sellercolletcionquotes,

            – prabhakaran7
            Apr 8 at 12:08






          • 1





            i make mistake ** ->addFieldToSelect('quote_id',$quoteId)** addFieldsToFIlter instead select

            – prabhakaran7
            yesterday















          0














          Try this one, adding getCollection():



          public function getsellerupdateCollection($quoteId,$sellerid)

          if ($quoteId != 0)
          $collection = $this->_sellercolletcionquotes
          ->create()->getCollection()
          ->addFieldToSelect('quote_id',$quoteId)
          ->addFieldToFilter('main_table.status',array('in'=>array('1','2')))
          ->addFieldToFilter('main_table.seller_id',['neq'=>$sellerid])
          ->addFieldToFilter('main_table.nstatus',1);

          foreach($collections as $item)

          $item->setNstatus('Sold');
          $item->save();

          $this->_sellercolletcionquotes = $collection;

          return $this->_sellercolletcionquotes;






          share|improve this answer

























          • where i can use save(); - method

            – prabhakaran7
            Apr 8 at 12:05











          • updated the answer

            – magefms
            Apr 8 at 12:06











          • Uncaught Error: Call to undefined method in Resource model Collection::getCollection() in /var/www/html/*

            – prabhakaran7
            Apr 8 at 12:07












          • i already defined in constract WebkulMpquotesystemModelResourceModelSellerQuotesCollectionFactory $sellercolletcionquotes,

            – prabhakaran7
            Apr 8 at 12:08






          • 1





            i make mistake ** ->addFieldToSelect('quote_id',$quoteId)** addFieldsToFIlter instead select

            – prabhakaran7
            yesterday













          0












          0








          0







          Try this one, adding getCollection():



          public function getsellerupdateCollection($quoteId,$sellerid)

          if ($quoteId != 0)
          $collection = $this->_sellercolletcionquotes
          ->create()->getCollection()
          ->addFieldToSelect('quote_id',$quoteId)
          ->addFieldToFilter('main_table.status',array('in'=>array('1','2')))
          ->addFieldToFilter('main_table.seller_id',['neq'=>$sellerid])
          ->addFieldToFilter('main_table.nstatus',1);

          foreach($collections as $item)

          $item->setNstatus('Sold');
          $item->save();

          $this->_sellercolletcionquotes = $collection;

          return $this->_sellercolletcionquotes;






          share|improve this answer















          Try this one, adding getCollection():



          public function getsellerupdateCollection($quoteId,$sellerid)

          if ($quoteId != 0)
          $collection = $this->_sellercolletcionquotes
          ->create()->getCollection()
          ->addFieldToSelect('quote_id',$quoteId)
          ->addFieldToFilter('main_table.status',array('in'=>array('1','2')))
          ->addFieldToFilter('main_table.seller_id',['neq'=>$sellerid])
          ->addFieldToFilter('main_table.nstatus',1);

          foreach($collections as $item)

          $item->setNstatus('Sold');
          $item->save();

          $this->_sellercolletcionquotes = $collection;

          return $this->_sellercolletcionquotes;







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Apr 8 at 12:05

























          answered Apr 8 at 12:02









          magefmsmagefms

          2,6352528




          2,6352528












          • where i can use save(); - method

            – prabhakaran7
            Apr 8 at 12:05











          • updated the answer

            – magefms
            Apr 8 at 12:06











          • Uncaught Error: Call to undefined method in Resource model Collection::getCollection() in /var/www/html/*

            – prabhakaran7
            Apr 8 at 12:07












          • i already defined in constract WebkulMpquotesystemModelResourceModelSellerQuotesCollectionFactory $sellercolletcionquotes,

            – prabhakaran7
            Apr 8 at 12:08






          • 1





            i make mistake ** ->addFieldToSelect('quote_id',$quoteId)** addFieldsToFIlter instead select

            – prabhakaran7
            yesterday

















          • where i can use save(); - method

            – prabhakaran7
            Apr 8 at 12:05











          • updated the answer

            – magefms
            Apr 8 at 12:06











          • Uncaught Error: Call to undefined method in Resource model Collection::getCollection() in /var/www/html/*

            – prabhakaran7
            Apr 8 at 12:07












          • i already defined in constract WebkulMpquotesystemModelResourceModelSellerQuotesCollectionFactory $sellercolletcionquotes,

            – prabhakaran7
            Apr 8 at 12:08






          • 1





            i make mistake ** ->addFieldToSelect('quote_id',$quoteId)** addFieldsToFIlter instead select

            – prabhakaran7
            yesterday
















          where i can use save(); - method

          – prabhakaran7
          Apr 8 at 12:05





          where i can use save(); - method

          – prabhakaran7
          Apr 8 at 12:05













          updated the answer

          – magefms
          Apr 8 at 12:06





          updated the answer

          – magefms
          Apr 8 at 12:06













          Uncaught Error: Call to undefined method in Resource model Collection::getCollection() in /var/www/html/*

          – prabhakaran7
          Apr 8 at 12:07






          Uncaught Error: Call to undefined method in Resource model Collection::getCollection() in /var/www/html/*

          – prabhakaran7
          Apr 8 at 12:07














          i already defined in constract WebkulMpquotesystemModelResourceModelSellerQuotesCollectionFactory $sellercolletcionquotes,

          – prabhakaran7
          Apr 8 at 12:08





          i already defined in constract WebkulMpquotesystemModelResourceModelSellerQuotesCollectionFactory $sellercolletcionquotes,

          – prabhakaran7
          Apr 8 at 12:08




          1




          1





          i make mistake ** ->addFieldToSelect('quote_id',$quoteId)** addFieldsToFIlter instead select

          – prabhakaran7
          yesterday





          i make mistake ** ->addFieldToSelect('quote_id',$quoteId)** addFieldsToFIlter instead select

          – prabhakaran7
          yesterday













          0














          I have updated a few lines of code.



          public function getsellerupdateCollection($quoteId,$sellerid)

          if ($quoteId != 0)
          $collection = $this->_sellercolletcionquotes
          ->create()->getCollection()
          ->addFieldToSelect('quote_id',$quoteId)
          ->addFieldToFilter('main_table.status',array('in'=>array('1','2')))
          ->addFieldToFilter('main_table.seller_id',['neq'=>$sellerid])
          ->addFieldToFilter('main_table.nstatus',1);

          foreach($collections as $item)

          $item->setNstatus('Sold');
          $item->save();

          $this->_sellercolletcionquotes = $collection;

          return $this->_sellercolletcionquotes;






          share|improve this answer

























          • i will check .....................

            – prabhakaran7
            Apr 8 at 11:46











          • Why you are adding condition like this ->addFieldToFilter('main_table.seller_id',['neq'=>$sellerid]) instead of ->addFieldToFilter('main_table.seller_id',['eq'=>$sellerid])

            – Kamlesh Solanki
            Apr 8 at 11:48











          • i am omitting that customer for update...

            – prabhakaran7
            Apr 8 at 11:50











          • ok is that worked?

            – Kamlesh Solanki
            Apr 8 at 11:54











          • Actaully, what you want update it

            – Kamlesh Solanki
            Apr 8 at 11:56















          0














          I have updated a few lines of code.



          public function getsellerupdateCollection($quoteId,$sellerid)

          if ($quoteId != 0)
          $collection = $this->_sellercolletcionquotes
          ->create()->getCollection()
          ->addFieldToSelect('quote_id',$quoteId)
          ->addFieldToFilter('main_table.status',array('in'=>array('1','2')))
          ->addFieldToFilter('main_table.seller_id',['neq'=>$sellerid])
          ->addFieldToFilter('main_table.nstatus',1);

          foreach($collections as $item)

          $item->setNstatus('Sold');
          $item->save();

          $this->_sellercolletcionquotes = $collection;

          return $this->_sellercolletcionquotes;






          share|improve this answer

























          • i will check .....................

            – prabhakaran7
            Apr 8 at 11:46











          • Why you are adding condition like this ->addFieldToFilter('main_table.seller_id',['neq'=>$sellerid]) instead of ->addFieldToFilter('main_table.seller_id',['eq'=>$sellerid])

            – Kamlesh Solanki
            Apr 8 at 11:48











          • i am omitting that customer for update...

            – prabhakaran7
            Apr 8 at 11:50











          • ok is that worked?

            – Kamlesh Solanki
            Apr 8 at 11:54











          • Actaully, what you want update it

            – Kamlesh Solanki
            Apr 8 at 11:56













          0












          0








          0







          I have updated a few lines of code.



          public function getsellerupdateCollection($quoteId,$sellerid)

          if ($quoteId != 0)
          $collection = $this->_sellercolletcionquotes
          ->create()->getCollection()
          ->addFieldToSelect('quote_id',$quoteId)
          ->addFieldToFilter('main_table.status',array('in'=>array('1','2')))
          ->addFieldToFilter('main_table.seller_id',['neq'=>$sellerid])
          ->addFieldToFilter('main_table.nstatus',1);

          foreach($collections as $item)

          $item->setNstatus('Sold');
          $item->save();

          $this->_sellercolletcionquotes = $collection;

          return $this->_sellercolletcionquotes;






          share|improve this answer















          I have updated a few lines of code.



          public function getsellerupdateCollection($quoteId,$sellerid)

          if ($quoteId != 0)
          $collection = $this->_sellercolletcionquotes
          ->create()->getCollection()
          ->addFieldToSelect('quote_id',$quoteId)
          ->addFieldToFilter('main_table.status',array('in'=>array('1','2')))
          ->addFieldToFilter('main_table.seller_id',['neq'=>$sellerid])
          ->addFieldToFilter('main_table.nstatus',1);

          foreach($collections as $item)

          $item->setNstatus('Sold');
          $item->save();

          $this->_sellercolletcionquotes = $collection;

          return $this->_sellercolletcionquotes;







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Apr 8 at 12:19

























          answered Apr 8 at 11:45









          Kamlesh SolankiKamlesh Solanki

          1656




          1656












          • i will check .....................

            – prabhakaran7
            Apr 8 at 11:46











          • Why you are adding condition like this ->addFieldToFilter('main_table.seller_id',['neq'=>$sellerid]) instead of ->addFieldToFilter('main_table.seller_id',['eq'=>$sellerid])

            – Kamlesh Solanki
            Apr 8 at 11:48











          • i am omitting that customer for update...

            – prabhakaran7
            Apr 8 at 11:50











          • ok is that worked?

            – Kamlesh Solanki
            Apr 8 at 11:54











          • Actaully, what you want update it

            – Kamlesh Solanki
            Apr 8 at 11:56

















          • i will check .....................

            – prabhakaran7
            Apr 8 at 11:46











          • Why you are adding condition like this ->addFieldToFilter('main_table.seller_id',['neq'=>$sellerid]) instead of ->addFieldToFilter('main_table.seller_id',['eq'=>$sellerid])

            – Kamlesh Solanki
            Apr 8 at 11:48











          • i am omitting that customer for update...

            – prabhakaran7
            Apr 8 at 11:50











          • ok is that worked?

            – Kamlesh Solanki
            Apr 8 at 11:54











          • Actaully, what you want update it

            – Kamlesh Solanki
            Apr 8 at 11:56
















          i will check .....................

          – prabhakaran7
          Apr 8 at 11:46





          i will check .....................

          – prabhakaran7
          Apr 8 at 11:46













          Why you are adding condition like this ->addFieldToFilter('main_table.seller_id',['neq'=>$sellerid]) instead of ->addFieldToFilter('main_table.seller_id',['eq'=>$sellerid])

          – Kamlesh Solanki
          Apr 8 at 11:48





          Why you are adding condition like this ->addFieldToFilter('main_table.seller_id',['neq'=>$sellerid]) instead of ->addFieldToFilter('main_table.seller_id',['eq'=>$sellerid])

          – Kamlesh Solanki
          Apr 8 at 11:48













          i am omitting that customer for update...

          – prabhakaran7
          Apr 8 at 11:50





          i am omitting that customer for update...

          – prabhakaran7
          Apr 8 at 11:50













          ok is that worked?

          – Kamlesh Solanki
          Apr 8 at 11:54





          ok is that worked?

          – Kamlesh Solanki
          Apr 8 at 11:54













          Actaully, what you want update it

          – Kamlesh Solanki
          Apr 8 at 11:56





          Actaully, what you want update it

          – Kamlesh Solanki
          Apr 8 at 11:56

















          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%2f269139%2fhow-to-update-record-using-multiple-conditions-in-collectionfactory-magento-2%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

          Sum ergo cogito? 1 nng

          419 nièngy_Soadمي 19bal1.5o_g

          Queiggey Chernihivv 9NnOo i Zw X QqKk LpB