CommerceML (entity_id)

Как получить entity_id используя local_id?

Пытался использовать метод “findEntityIds”, но выдает ошибку

Error

Message

Using $this when not in object context

Error at

app/addons/commerceml/src/Repository/ImportEntityMapRepository.php, line: 194

app/functions/fn.products.php


function fn_gather_additional_products_data(&$products, $params, $lang_code = CART_LANGUAGE)
{
    foreach ($products as &$_product) {
        $product = $_product;
        $product_id = $product['product_id'];

        $product['entity_id'] = ImportEntityMapRepository::findEntityIds('product', $product_id);

Вариант “хардкода”

function fn_gather_additional_products_data(&$products, $params, $lang_code = CART_LANGUAGE)
{
    foreach ($products as &$_product) {
        $product = $_product;
        $product_id = $product['product_id'];
        $product['entity_id'] = db_get_field("SELECT entity_id FROM ?:commerceml_import_entity_map WHERE local_id = ?i", $product_id);

        if ($product['entity_id'] === null) {
            unset($product['entity_id']);
        }