<?php 

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly


function mdspbe_atum_get_product( $product_id ) {
    $atum_product = \Atum\Inc\Helpers::get_atum_product( $product_id );
    return $atum_product;
}


function mdspbe_atum_list_suppliers( $include_empty_opt = true, $cache = true ) {

    if ( $cache ) {
        static $suppliers;
        if ( ! is_null( $suppliers ) ) {
            return $suppliers;
        }
    }

    $suppliers_ids = get_posts( [
        'post_type'      => 'atum_supplier',
        'numberposts'    => -1,
        'post_status'    => ['publish'],
        'orderby'        => 'title',
        'order'          => 'ASC',
        'fields'         => 'ids',
    ] );

    $suppliers = $include_empty_opt ? ['' => ''] : [];
    foreach ( $suppliers_ids as $supplier_id ) {
        $suppliers[$supplier_id] = get_the_title( $supplier_id );
    }

    return $suppliers;
}

