1

We have this API where we save different fields, but the object $lines we have created doesn't save properly. The code below are the getters and setters for the object $lines.

Save method API:

public function save(\Vendor\SizeCurves\Api\Data\SizeCurvesInterface $sizeCurves)
    {
        if (
            ($object = $this->get($sizeCurves->getExternalKey()))
        ) {
            $sizeCurves = $this->updateData($object, $sizeCurves);
        }

        try {
            $this->sizeCurvesResource->save($sizeCurves);
        } catch (ValidatorException $e) {
            throw new CouldNotSaveException(__($e->getMessage()));
        } catch (\Exception $e) {
            throw new CouldNotSaveException(__('Unable to save size curve %1', $sizeCurves->getExternalKey()));
        }

        return $sizeCurves;
    }

Model of SizeCurvesInterface:

    /**
     * @param \Vendor\SizeCurves\Api\Data\SizeCurvesLinesInterface[] $lines
     * @return mixed
     */
    public function setLines(array $lines = null)
    {
        $this->setData('lines', $lines);
        return $this;
    }

    /**
     * @return \Vendor\SizeCurves\Api\Data\SizeCurvesLinesInterface[]
     */
    public function getLines()
    {
        return $this->getData('lines');
    }

Interface:

/**
 * @return \Vendor\SizeCurves\Api\Data\SizeCurvesLinesInterface[]
 */
public function getLines();

/**
 * @param \Vendor\SizeCurves\Api\Data\SizeCurvesLinesInterface[] $lines
 * @return mixed
 */
public function setLines(array $lines = null);

Here you can see the answer I receive with postman, where I don't receive any information about $lines

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.