0

I'm trying to get order purchase point (store where it was purchased), I have tried this:

$order->getPurchasePoint();

It did not work, any ideas?

here is my code

 public function execute()
    {
       
        $date = date('m-d-Y');
        $filepath = 'export/orders-'.$date.'.csv';
        $this->directory->create('export');
        $stream = $this->directory->openFile($filepath, 'w+');
        $stream->lock();
 
        $header = ['Id', 'Status','Store'];
        $stream->writeCsv($header);
        $collection = $this->getOrderCollection();
        
        foreach ($collection as $order) {
            $data = [];
            $data[] = $order->getId();
            $data[] = $order->getStatus();
            $data[] = $order->getPurchasePoint();
            $stream->writeCsv($data);
        }


    }

    public function getOrderCollection() 
    {
    $collection = $this->orderCollection->create()
    ->addAttributeToSelect('*')
    ->setOrder('created_at','desc');
    return $collection;
    }
1

I have found the way.

This is the way to get the storeview name of the order and the name.

$store_name = $_order->getStore()->getGroup()->getName()  //store name
$store_view_name = $_order->getStore()->getName();

In this website you can find more methods

https://www.rootways.com/blog/magento-2-how-to-get-store-information-of-order

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.