I added a new attribute to a product. The attribute is named "is_brand_new". The product shows in the catalog product view in the upselling and related slider.

But the new attribute is not in the product data. I even cleared the cache

I outputted all the data from the item


if ($_item->getData("name") == "t-shirt") {

But it does not contain the data for the attribute is_brand_new.

What I try to do is show an icon if the product is marked as brandnew. So I added a new checkbox attribute in the backend. Now I try to read it out and show the icon if the checkbox is enabled.

2 Answers 2


It looks like the block classes prepareData method is only loading a few attributes. So I had to create a helper, load the full product via the ID, then I was able to load the attribute.


use \Magento\Catalog\Model\ProductRepository;


public function getProductByIdAndReturnData($id, $key)
    $product = $this->getProductById($id);
    if (empty($product)) { return $this; }

    $data = $product->getData($key);
    return $data;

public function getProductById($id)
    return $this->_productRepository->getById($id);


$isProductBrandNew = $productHelper->getProductByIdAndReturnData($id, "is_brand_new");

If you setup thr product attribute to be visible in front from the backend as per the screenshot below, the attribute should appear.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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