/**
  * set all attributes in recommender by manifest file
  *
  * TODO: do not set existing attributes
  * TODO: set metatypes
  *
  */
 public function setAttributes(DataApi\Client $client)
 {
     if (!is_null($this->manifest)) {
         $itemsAttributes = $client->getItemsAttributes();
         $itemsAttributesNames = array_map(function ($attr) {
             return $attr['name'];
         }, $itemsAttributes['attributes']);
         foreach ($this->manifest->getColumns() as $attribute) {
             $pk = $this->manifest->getPrimaryKey()[0];
             if ($attribute != $pk && !in_array($attribute, $itemsAttributesNames)) {
                 $client->addItemsAttribute($attribute, DataApi\DataType::TEXT);
             }
         }
     }
     return $this;
 }
 /**
  * @return void
  */
 private function refreshItemsAttributes()
 {
     $expectedAttributes = [self::ATTRIBUTE_NAME, self::ATTRIBUTE_DESCRIPTION, self::ATTRIBUTE_WEIGHT];
     $actualAttributes = $this->getAttributesNames($this->client->getItemsAttributes());
     foreach ($actualAttributes as $attribute) {
         if (!in_array($attribute, $expectedAttributes)) {
             $this->client->deleteItemsAttribute($attribute);
         }
     }
     if (!in_array(self::ATTRIBUTE_NAME, $actualAttributes)) {
         $this->client->addItemsAttribute(self::ATTRIBUTE_NAME, DataType::TEXT, 'en', MetaType::TITLE);
     }
     if (!in_array(self::ATTRIBUTE_DESCRIPTION, $actualAttributes)) {
         $this->client->addItemsAttribute(self::ATTRIBUTE_DESCRIPTION, DataType::TEXT, 'en');
     }
     if (!in_array(self::ATTRIBUTE_WEIGHT, $actualAttributes)) {
         $this->client->addItemsAttribute(self::ATTRIBUTE_WEIGHT, DataType::INTEGER);
     }
 }