本文整理汇总了PHP中Pim\Component\Catalog\Model\ProductInterface::getCompletenesses方法的典型用法代码示例。如果您正苦于以下问题:PHP ProductInterface::getCompletenesses方法的具体用法?PHP ProductInterface::getCompletenesses怎么用?PHP ProductInterface::getCompletenesses使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pim\Component\Catalog\Model\ProductInterface
的用法示例。
在下文中一共展示了ProductInterface::getCompletenesses方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ArrayCollection
function it_provide_product_completeness_if_a_family_is_defined($familyRepository, $productValueCompleteChecker, QueryBuilder $qb, AbstractQuery $query, AttributeRequirementInterface $requirement, ProductInterface $product, ChannelInterface $mobile, LocaleInterface $en, FamilyInterface $shirt, CompletenessInterface $completeness, ProductValueInterface $nameValue, AttributeInterface $name)
{
$product->getFamily()->willReturn($shirt);
$product->getCompletenesses()->willReturn([$completeness]);
$en->getCode()->willReturn('en_US');
$mobile->getCode()->willReturn('mobile');
$completeness->getLocale()->willReturn($en);
$completeness->getChannel()->willReturn($mobile);
$completeness->getMissingCount()->willReturn(1);
$familyRepository->getFullRequirementsQB($shirt, 'en_US')->willReturn($qb);
$qb->getQuery()->willReturn($query);
$query->getResult()->willReturn([$requirement]);
$requirement->getChannel()->willReturn($mobile);
$requirement->getAttribute()->willReturn($name);
$requirement->isRequired()->willReturn(true);
$name->getCode()->willReturn('name');
$name->isLocalizable()->willreturn(true);
$name->isScopable()->willReturn(false);
$name->isLocaleSpecific()->willReturn(true);
$name->hasLocaleSpecific($en)->willReturn(false);
$product->getValues()->willReturn(new ArrayCollection());
$productValueCompleteChecker->supportsValue($nameValue);
$productValueCompleteChecker->isComplete($nameValue, $mobile, $en);
$this->getProductCompleteness($product, [$mobile], [$en], 'en_US')->shouldReturn([['channels' => [['completeness' => $completeness, 'missing' => []]], 'stats' => ['total' => 1, 'complete' => 0], 'locale' => 'en_US']]);
}
示例2: array
function it_normalizes_product(SerializerInterface $serializer, ProductInterface $product, FamilyInterface $family, Completeness $completeness)
{
$serializer->implement('Symfony\\Component\\Serializer\\Normalizer\\NormalizerInterface');
$this->setSerializer($serializer);
$product->getFamily()->willReturn($family);
$product->getGroups()->willReturn([]);
$product->getValues()->willReturn([]);
$product->getCompletenesses()->willReturn([$completeness]);
$product->getCreated()->willReturn(null);
$product->getUpdated()->willReturn(null);
$product->isEnabled()->willReturn(true);
$serializer->normalize($family, 'mongodb_json', [])->willReturn('family normalization');
$serializer->normalize($completeness, 'mongodb_json', [])->willReturn(['completenessCode' => 'completeness normalization']);
$this->normalize($product, 'mongodb_json', [])->shouldReturn([ProductNormalizer::FAMILY_FIELD => 'family normalization', ProductNormalizer::COMPLETENESSES_FIELD => array('completenessCode' => 'completeness normalization'), ProductNormalizer::ENABLED_FIELD => true]);
}
示例3: getProductCompleteness
/**
* Returns an array containing all completeness info and missing attributes for a product
*
* @param ProductInterface $product
* @param \Pim\Bundle\CatalogBundle\Entity\ChannelInterface[] $channels
* @param \Pim\Bundle\CatalogBundle\Entity\LocaleInterface[] $locales
* @param string $localeCode
*
* @return array
*/
public function getProductCompleteness(ProductInterface $product, array $channels, array $locales, $localeCode)
{
$family = $product->getFamily();
$getCodes = function ($entities) {
return array_map(function ($entity) {
return $entity->getCode();
}, $entities);
};
$channelCodes = $getCodes($channels);
$localeCodes = $getCodes($locales);
$channelTemplate = ['channels' => array_fill_keys($channelCodes, ['completeness' => null, 'missing' => []]), 'stats' => ['total' => 0, 'complete' => 0]];
$completenesses = array_fill_keys($localeCodes, $channelTemplate);
if (!$family) {
return $completenesses;
}
$allCompletenesses = $product->getCompletenesses();
foreach ($allCompletenesses as $completeness) {
$locale = $completeness->getLocale();
$channel = $completeness->getChannel();
$compLocaleCode = $locale->getCode();
if (isset($completenesses[$compLocaleCode])) {
$completenesses[$compLocaleCode]['channels'][$channel->getCode()]['completeness'] = $completeness;
$completenesses[$compLocaleCode]['stats']['total']++;
if (0 === $completeness->getMissingCount()) {
$completenesses[$compLocaleCode]['stats']['complete']++;
}
}
}
$requirements = $this->familyRepository->getFullRequirementsQB($family, $localeCode)->getQuery()->getResult();
$productValues = $product->getValues();
foreach ($requirements as $requirement) {
if ($requirement->isRequired()) {
$this->addRequirementToCompleteness($completenesses, $requirement, $productValues, $locales);
}
}
return $completenesses;
}
示例4: schedule
/**
* {@inheritdoc}
*/
public function schedule(ProductInterface $product)
{
foreach ($product->getCompletenesses() as $completeness) {
$this->manager->remove($completeness);
}
$product->getCompletenesses()->clear();
}
示例5: schedule
/**
* {@inheritdoc}
*/
public function schedule(ProductInterface $product)
{
$product->getCompletenesses()->clear();
}
示例6: fillCompletenessesTemplate
/**
* Returns completenesses filled
*
* @param array $completenesses
* @param ProductInterface $product
* @param array $locales
* @param string $localeCode
*
* @return array
*/
protected function fillCompletenessesTemplate(array $completenesses, ProductInterface $product, array $locales, $localeCode)
{
$allCompletenesses = $product->getCompletenesses();
foreach ($allCompletenesses as $completeness) {
$locale = $completeness->getLocale();
$channel = $completeness->getChannel();
$compLocaleCode = $locale->getCode();
if (isset($completenesses[$compLocaleCode])) {
$completenesses[$compLocaleCode]['channels'][$channel->getCode()]['completeness'] = $completeness;
$completenesses[$compLocaleCode]['locale'] = $compLocaleCode;
$completenesses[$compLocaleCode]['stats']['total']++;
if (0 === $completeness->getMissingCount()) {
$completenesses[$compLocaleCode]['stats']['complete']++;
}
}
}
$requirements = $this->familyRepository->getFullRequirementsQB($product->getFamily(), $localeCode)->getQuery()->getResult();
$productValues = $product->getValues();
foreach ($requirements as $requirement) {
if ($requirement->isRequired()) {
$this->addRequirementToCompleteness($completenesses, $requirement, $productValues, $locales);
}
}
return $completenesses;
}