/** * Unserialize after loading * * @param \Magento\Framework\DataObject $object * @return $this */ public function afterLoad($object) { parent::afterLoad($object); $this->_unserialize($object); return $this; }
/** * Set category ids to product data * * @param \Magento\Catalog\Model\Product $object * @return $this */ public function afterLoad($object) { $object->setData($this->getAttribute()->getAttributeCode(), $object->getCategoryIds()); return parent::afterLoad($object); }
/** * Set inventory data to custom attribute * * @param Product $object * @return $this */ public function afterLoad($object) { $stockItem = $this->stockRegistry->getStockItem($object->getId(), $object->getStore()->getWebsiteId()); $object->setData($this->getAttribute()->getAttributeCode(), ['is_in_stock' => $stockItem->getIsInStock(), 'qty' => $stockItem->getQty()]); return parent::afterLoad($object); }
/** * Set inventory data to custom attribute * * @param Product $object * @return $this */ public function afterLoad($object) { $stockItemDo = $this->stockItemService->getStockItem($object->getId()); $object->setData($this->getAttribute()->getAttributeCode(), array('is_in_stock' => $stockItemDo->getIsInStock(), 'qty' => $stockItemDo->getQty())); return parent::afterLoad($object); }