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?

Can withdrawing asylum be illegal?

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

How to display lines in a file like ls displays files in a directory?

Kerning for subscripts of sigma?

Compute the product of 3 dictionaries and concatenate keys and values

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

Accepted by European university, rejected by all American ones I applied to? Possible reasons?

Worn-tile Scrabble

Is it safe to harvest rainwater that fell on solar panels?

Can a flute soloist sit?

What information about me do stores get via my credit card?

Is bread bad for ducks?

Why don't hard Brexiteers insist on a hard border to prevent illegal immigration after Brexit?

Will it cause any balance problems to have PCs level up and gain the benefits of a long rest mid-fight?

Correct punctuation for showing a character's confusion

The phrase "to the numbers born"?

Is it okay to consider publishing in my first year of PhD?

What does Linus Torvalds mean when he says that Git "never ever" tracks a file?

How much of the clove should I use when using big garlic heads?

Cooking pasta in a water boiler

Keeping a retro style to sci-fi spaceships?

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

Did the UK government pay "millions and millions of dollars" to try to snag Julian Assange?

Why couldn't they take pictures of a closer black hole?



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

          Bulk add to cart function issuecart vs. mini cart issue … rwd themeRedirect Add to cart button to cart pageAdd to cart issue - Magento 2.1The requested Payment Method is not available When creating an orderM2: reason add-to-cart might not function in production modeAdd to cart issue in some android devicesMagento 2 - custom price can not add to subtotal and grand total after add to cartAdd to cart codeIssue with my cart module on pdp and cart pages, just keeps spinningBulk price and quantity update using rest api

          Magento2 - How to hide price filter only in specific categories?Multiselect price filter attribute in layered navigationhide only some categories from layered navigation in magentoRemove Price Filter on certain categoriescustomize layered price filter?Hide Price for a particular customer groupPrice filter in layered navigation not working correctly with price including tax in magento 2.2.3Magento 2 how to hide attribute at Layered navigation?Magento 2. how to hide price only for specific categoriesMagento 2 How can I hide the price and total from cart and checkout summary?Magento2: Can we add navigation layered filter like price filter for other attribute?