Cuando una integración externa necesita datos de Magento, crear un endpoint propio suele ser la opcion más limpia.
Declarar ruta en webapi.xml
<?xml version="1.0"?><routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Webapi:etc/webapi.xsd"> <route url="/V1/gdw/health" method="GET"> <service class="GDW\Hello\Api\HealthInterface" method="getStatus"/> <resources> <resource ref="anonymous"/> </resources> </route></routes>Interfaz y modelo
<?phpnamespace GDW\Hello\Api;
interface HealthInterface{ public function getStatus(): array;}<?phpnamespace GDW\Hello\Model;
use GDW\Hello\Api\HealthInterface;
class Health implements HealthInterface{ public function getStatus(): array { return ['status' => 'ok', 'module' => 'GDW_Hello']; }}Mapear preferencia
<preference for="GDW\Hello\Api\HealthInterface" type="GDW\Hello\Model\Health"/>Conclusión
Con este patron puedes construir APIs internas robustas y desacopladas para ERP, CRMs o frontends headless.