/**
  * Insert/update attribute in the entry
  *
  * @param \Magento\Framework\Gdata\Gshopping\Entry $entry
  * @param string $name
  * @param string $type
  * @param string $value
  * @param string $unit
  * @return \Magento\Framework\Gdata\Gshopping\Entry
  */
 protected function _setAttribute($entry, $name, $type = self::ATTRIBUTE_TYPE_TEXT, $value = '', $unit = null)
 {
     if (is_object($value) || (string) $value != $value) {
         throw new \Magento\Framework\Exception\LocalizedException(__('Please correct the attribute "%1" type for Google Shopping. The product with this attribute hasn\'t been updated in Google Content.', $name));
     }
     $attribute = $entry->getContentAttributeByName($name);
     if ($attribute instanceof \Magento\Framework\Gdata\Gshopping\Extension\Attribute) {
         $attribute->text = (string) $value;
         $attribute->type = $type;
         if (!is_null($unit)) {
             $attribute->unit = $unit;
         }
     } else {
         $entry->addContentAttribute($name, $value, $type, $unit);
     }
     return $entry;
 }