Skip to main content
added 175 characters in body
Source Link
Nagaraju Kasa
  • 5.9k
  • 8
  • 58
  • 114

Here this is the Magento 1 code would like to convert to M2 code.

$customerId = 1;
$orderCollection = Mage::getResourceModel('sales/order_collection')
        ->addFieldToSelect('*')
        ->addFieldToFilter('customer_id', $customerId)
        ->addFieldToFilter('state', array('in' => Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates()))
        ->setOrder('created_at', 'desc');

Here mainly need to know how to add ->addFieldToFilter('state', array('in' => Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates())) statement in Magento2

Thanks

Here this is the Magento 1 code would like to convert to M2 code.

$customerId = 1;
$orderCollection = Mage::getResourceModel('sales/order_collection')
        ->addFieldToSelect('*')
        ->addFieldToFilter('customer_id', $customerId)
        ->addFieldToFilter('state', array('in' => Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates()))
        ->setOrder('created_at', 'desc');

Thanks

Here this is the Magento 1 code would like to convert to M2 code.

$customerId = 1;
$orderCollection = Mage::getResourceModel('sales/order_collection')
        ->addFieldToSelect('*')
        ->addFieldToFilter('customer_id', $customerId)
        ->addFieldToFilter('state', array('in' => Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates()))
        ->setOrder('created_at', 'desc');

Here mainly need to know how to add ->addFieldToFilter('state', array('in' => Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates())) statement in Magento2

Thanks

Source Link
Nagaraju Kasa
  • 5.9k
  • 8
  • 58
  • 114

Convert M1 code to M2 code

Here this is the Magento 1 code would like to convert to M2 code.

$customerId = 1;
$orderCollection = Mage::getResourceModel('sales/order_collection')
        ->addFieldToSelect('*')
        ->addFieldToFilter('customer_id', $customerId)
        ->addFieldToFilter('state', array('in' => Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates()))
        ->setOrder('created_at', 'desc');

Thanks