Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Product -> Response -> ModelListResponse #53

Open
Eayshwary opened this issue Jan 31, 2019 · 0 comments
Open

Product -> Response -> ModelListResponse #53

Eayshwary opened this issue Jan 31, 2019 · 0 comments

Comments

@Eayshwary
Copy link

this function

protected function _addProductModel($productModelXML)
{
$productModel = new ProductModel(intval($productModelXML['ModelId']));
$productModel->setCategoryCode($productModelXML['CategoryCode']);
$productModel->setName($productModelXML['Name']);
foreach ($productModelXML['Definition']['ListProperties']['a:KeyValueOfstringArrayOfstringty7Ep6D1'] as $keyValueXml) {
$keyvalueObj = new KeyValueProperty($keyValueXml['a:Key']);
foreach ($keyValueXml['a:Value']['a:string'] as $value) {
$keyvalueObj->addValue($value);
}
$productModel->addKeyValueProperty($keyvalueObj);
}
if (isset($productModelXML['Definition']['MandatoryModelProperties']) && !SoapTools::isSoapValueNull($productModelXML['Definition']['MandatoryModelProperties'])
&& isset($productModelXML['Definition']['MandatoryModelProperties']['a:string'])) {
var_dump($productModelXML['Definition']['MandatoryModelProperties']);
foreach ($productModelXML['Definition']['MandatoryModelProperties']['a:string'] as $mandatoryModelProperty) {
$productModel->addMandatoryModelProperty($mandatoryModelProperty);
}
}
array_push($this->_modelList, $productModel);
}

needs a var_dump removed as this displays the model list while calling this function and

if $productModelXML['Definition']['MandatoryModelProperties']['a:string'] this is not an array to which there is foreach loop on this statement --> there is fatal error

solution:

protected function _addProductModel($productModelXML)
{
$productModel = new ProductModel(intval($productModelXML['ModelId']));

    $productModel->setCategoryCode($productModelXML['CategoryCode']);
    $productModel->setName($productModelXML['Name']);

    foreach ($productModelXML['Definition']['ListProperties']['a:KeyValueOfstringArrayOfstringty7Ep6D1'] as $keyValueXml) {

        $keyvalueObj = new KeyValueProperty($keyValueXml['a:Key']);

        foreach ($keyValueXml['a:Value']['a:string'] as $value) {
            $keyvalueObj->addValue($value);
        }

        $productModel->addKeyValueProperty($keyvalueObj);
    }

    if (isset($productModelXML['Definition']['MandatoryModelProperties']) && !SoapTools::isSoapValueNull($productModelXML['Definition']['MandatoryModelProperties'])
        && isset($productModelXML['Definition']['MandatoryModelProperties']['a:string'])) {

        if (!is_array($productModelXML['Definition']['MandatoryModelProperties']['a:string'])) {
            $productModelXML['Definition']['MandatoryModelProperties']['a:string'] =
                array($productModelXML['Definition']['MandatoryModelProperties']['a:string']);
        }
        foreach ($productModelXML['Definition']['MandatoryModelProperties']['a:string'] as $mandatoryModelProperty) {
            $productModel->addMandatoryModelProperty($mandatoryModelProperty);
        }
    }

    array_push($this->_modelList, $productModel);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant