Search code examples
objectpimcore

Pimcore - Related Object Values not getting


Hi i am working on pimcore project.

I have Product Class which stores product details.

In Product details I have one field manufacturer which is refer another class Manufacturer.

Using custom plugin save event i am getting both Product and Manufacturer data.

But when i try with cron job i am not getting Related (Manufacturer) object values.

Below is the code which is i am using to get object details.

$list = new Object_Product_List();
$list->setCondition('o_id = ?', $objectId);
foreach($list as $list_data)
        {
            $productdata = (array)($list_data);
            echo "<pre>";
            print_r($productdata);
            exit;
        }

I am getting output like below.

Array
(
    [o_classId] => 15
    [o_className] => Product
    [name] => WS-KD WALL SHELVES
    [sku] => HWS-KD-36
    [enable] => 1
    [visibility] => 4
    [manufacturer] =>  // But this value is empty not getting Manufacturer value.
    ...........
    ......... So on
)

Please help me where do i made mistake. How to get related object values ?

Thanks


Solution

  • Why did you used product list when you try get only one element? O_id is unique value. You can get the product by using getter:

    Product::getById($objectId);
    

    When creating a class, you checked the 'lazy loading' options at the manufacture field?