我想在Akeneo中创建一个新的变体组,其中包含一些固定属性来“模拟”产品系列的行为。不幸的是,我不知道如何使用带有空值的某些属性来获取 class NestedUser
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string Sport { get; set; }
public string Music { get; set; }
public string Food { get; set; }
public string Place { get; set; }
public void AddLikes(System.Collections.ObjectModel.Collection<Likes> likes)
{
foreach (Likes like in likes)
{
Sport += like.Sport + ",";
Music += like.Music + ",";
Food += like.Food + ",";
Place += like.Place + ",";
}
if (Sport != string.Empty)
{
Sport = Sport.Substring(0, Sport.Length - 1);
}
if (Music != string.Empty)
{
Music = Music.Substring(0, Music.Length - 1);
}
if (Food != string.Empty)
{
Food = Food.Substring(0, Food.Length - 1);
}
if (Place != string.Empty)
{
Place = Place.Substring(0, Place.Length - 1);
}
}
}
。
当我尝试下面的代码时,在Akeneo GUI中打开创建的变体组后出现错误:
ProductTemplate
我的代码如下所示:
Error: Option "attributes" must only contains instances of "Pim\Bundle\CatalogBundle\Entity\Attribute", got "Pim\Bundle\EnrichBundle\Form\Type\AvailableAttributesType"
答案 0 :(得分:5)
我建议您使用Pim\Bundle\CatalogBundle\Builder\ProductTemplateBuilder
为产品模板创建和添加属性。
这将确保使用空产品值正确创建产品模板。