How to access Magento order 'visible_on_front' property?

How to access Magento order 'visible_on_front' property?

October 14, 2026 · Illustrated author avatarBy Stefan Bogdanescu
How to access Magento order 'visible_on_front' property?

Accessing the Magento Order ‘visible_on_front’ Property: A Comprehensive Guide

If you’re looking to access or modify the ‘visible_on_front’ property of an order in Magento, you’ve come to the right place. In this post, we’ll explore how to interact with this property and provide clear instructions for your specific use case.

Understanding the ‘visible_on.front’ Property The ‘visible_on_front’ property determines whether an order is visible on the frontend (i.e., customer view) or not. By default, it’s set to 0 (false), meaning orders won’t be displayed in the customer’s account area until they are invoiced.

Accessing and Setting the ‘Visible On Front’ Property To access or modify this property, you’ll need to work with Magento objects through your controller or observer. Here’s how you can do it:

Option 1: Using a Controller You can use a custom controller to interact with orders and update their visibility status.

// Your controller file (e.g., controllers/Adminhtml/Manage Orders.php)

public function execute()
{
    $orderId = 1; // Replace this with the actual order ID

    $order = $this->_objectManager->create('Magento\Sales\Model\Order')->load($orderId);

    if ($order->getId()) {
        $order->setVisibleOnFront(1); // Set to 1 for visible, or 0 for invisible
        $order->save();
    }
}

Option 2: Using an Observer Observers are a powerful way to handle events in Magento. You can create an observer to intercept order status changes and update the ‘visible_on_front’ property accordingly.

// Your observer file (e.g., app/code/Vendor/Module/etc/events.xml)

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="sales_order_status_save_after">
        <observer name="update_visible_on_front" instance="Vendor\Module\Observer\UpdateVisibleOnFront"/>
    </event>
</config>

// Your observer class (app/code/Vendor/Module/Observer/UpdateVisibleOnFront.php)

public function execute(\Magento\Framework\Event\Observer $observer)
{
    $order = $observer->getOrder();

    if ($order->canShip()) {
        $order->setVisibleOnFront(1); // Set to 1 for visible
        $order->save();
    }
}

Remember, when working with Magento objects and properties, it’s always a good idea to ensure that you’re following the correct naming conventions and using the appropriate methods provided by the framework. For more detailed information on object management and event handling in Magento, we recommend checking out our comprehensive guide at Laravel Company: Managing Objects in Magento.

Conclusion As you can see, accessing and modifying the ‘visible_on_front’ property of a Magento order is a straightforward process. By using controllers or observers, you can easily update this property based on your specific business logic.

Whether you’re looking to display orders in the customer account area after invoicing, or you need to hide certain orders for privacy reasons, understanding how to work with this property will help you build more powerful and flexible Magento extensions.

Don’t forget to explore our other tutorials at Laravel Company for more tips on Magento development best practices and advanced features. Happy coding!

Extensions Admin Configuration Orders

Our network