0

Trying to load model by name from a category factory:

    $categoryModel = $this->_categoryFactory->create();
    $categoryModel->loadByAttribute('name', 'Other');
    return $categoryModel->toArray(); // this is empty for some reason

I debugged that in resource model, collection query is crafted properly, but why i can't make getData on $categoryModel?

The categoryModel is Magento\Catalog\Model\Category\Interceptor instance, and _data property for some reason is empty, how cat i obtain data from loaded model ?

PS

When I try to load it with load($categoryId) I am not able to make getData().

0

solution was to pass return variable:

$categoryModel = $categoryModel->loadByAttribute('name', 'Other');

and then

$data = $categoryModel->getData()

| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.