当前位置: 首页>>代码示例>>PHP>>正文


PHP ProductInterface::getId方法代码示例

本文整理汇总了PHP中Pim\Component\Catalog\Model\ProductInterface::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP ProductInterface::getId方法的具体用法?PHP ProductInterface::getId怎么用?PHP ProductInterface::getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pim\Component\Catalog\Model\ProductInterface的用法示例。


在下文中一共展示了ProductInterface::getId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: use

 function it_hydrates_a_result_record(Builder $builder, Query $query, ProductInterface $product, Association $association, AssociationType $associationType, ProductInterface $associatedProduct1, ProductInterface $associatedProduct2, ArrayCollection $productsCollection, ArrayCollection $productIdsCollection, ArrayIterator $productsIterator, ArrayCollection $associationsCollection, ArrayIterator $associationsIterator, ArrayIterator $arrayIterator)
 {
     $product->getId()->willReturn('110ae6b98ead0ee8778b46bb');
     $options = ['locale_code' => 'en_US', 'scope_code' => 'print', 'current_group_id' => null, 'attributes_configuration' => [], 'association_type_id' => 1, 'current_product' => $product];
     $builder->find()->willReturn($builder);
     $builder->count()->willReturn($builder);
     $builder->getQuery()->willReturn($query);
     $builder->hydrate(false)->willReturn($builder);
     $builder->setQueryArray(Argument::any())->willReturn($builder);
     $builder->limit(Argument::any())->willReturn($builder);
     $builder->skip(Argument::any())->willReturn($builder);
     $product->getAssociations()->willReturn($associationsCollection);
     $associationsCollection->getIterator()->willReturn($associationsIterator);
     $associationsIterator->rewind()->shouldBeCalled();
     $associationsCount = 1;
     $associationsIterator->valid()->will(function () use(&$associationsCount) {
         return $associationsCount-- > 0;
     });
     $associationsIterator->next()->shouldBeCalled();
     $associationsIterator->current()->will(new ReturnPromise([$association]));
     $associationsCollection->filter(Argument::any())->willReturn($associationsIterator);
     $associationsIterator->first()->willReturn($association);
     $association->getAssociationType()->willReturn($associationType);
     $associationType->getId()->willReturn(1);
     $associatedProduct1->getId()->willReturn('220ae6b98ead0ed7778b46bb');
     $associatedProduct2->getId()->willReturn('330ae6b98abd0ec8778b46bb');
     $association->getProducts()->willReturn($productsCollection);
     $productsCollection->getIterator()->willReturn($productsIterator);
     $productsIterator->rewind()->shouldBeCalled();
     $productsCount = 2;
     $productsIterator->valid()->will(function () use(&$productsCount) {
         return $productsCount-- > 0;
     });
     $associatedProduct1->getId()->willReturn('220ae6b98ead0ed7778b46bb');
     $associatedProduct2->getId()->willReturn('330ae6b98abd0ec8778b46bb');
     $association->getProducts()->willReturn($productsCollection);
     $productsCollection->getIterator()->willReturn($productsIterator);
     $productsIterator->rewind()->shouldBeCalled();
     $productsCount = 2;
     $productsIterator->valid()->will(function () use(&$productsCount) {
         return $productsCount-- > 0;
     });
     $productsIterator->next()->shouldBeCalled();
     $productsIterator->current()->will(new ReturnPromise([$associatedProduct1, $associatedProduct2]));
     $productsCollection->map(Argument::any())->willReturn($productIdsCollection);
     $productIdsCollection->toArray()->willReturn(['220ae6b98ead0ed7778b46bb', '330ae6b98abd0ec8778b46bb']);
     $queryDefinition = ['type' => 1, 'sort' => ['normalizedData.is_associated' => -1, '_id' => 1], 'limit' => 10, 'skip' => 0, 'query' => ['_id' => ['$ne' => \MongoId::__set_state(['$id' => '110ae6b98ead0ee8778b46bb'])]], 'newObj' => []];
     $query->getQuery()->willReturn($queryDefinition);
     $fixture = ['_id' => \MongoId::__set_state(['$id' => '550ae6b98ead0ee8778b46bb']), 'normalizedData' => [], 'sku' => ['attribute' => ['code' => 'sku', 'attributeType' => 'text', 'backendType' => 'text'], 'locale' => null, 'scope' => null, 'value' => 'mysku'], 'name' => ['attribute' => ['code' => 'name', 'attributeType' => 'text', 'backendType' => 'text'], 'locale' => 'fr_FR', 'scope' => null], 'desc' => ['attribute' => ['code' => 'desc', 'attributeType' => 'text', 'backendType' => 'text'], 'locale' => 'fr_FR', 'scope' => 'print'], 'is_associated' => 1];
     $query->execute()->willReturn($arrayIterator);
     $arrayIterator->toArray()->willReturn([$fixture]);
     $rows = $this->hydrate($builder, $options);
     $rows->shouldHaveCount(1);
     $firstResult = $rows[0];
     $firstResult->shouldBeAnInstanceOf('\\Oro\\Bundle\\DataGridBundle\\Datasource\\ResultRecord');
 }
开发者ID:userz58,项目名称:pim-community-dev,代码行数:56,代码来源:AssociatedProductHydratorSpec.php

示例2:

 function it_massively_insert_new_products_and_update_existing_products($documentManager, $collection, $normalizer, $mongoFactory, $pendingPersister, $eventDispatcher, ProductInterface $product1, ProductInterface $product2, ProductInterface $product3, ProductInterface $product4)
 {
     $mongoFactory->createMongoId()->willReturn('my_mongo_id');
     $product1->getId()->willReturn("my_product_1");
     $product2->getId()->willReturn(null);
     $product3->getId()->willReturn("my_product_3");
     $product4->getId()->willReturn(null);
     $product1->setId(Argument::any())->shouldNotBeCalled();
     $product2->setId('my_mongo_id')->shouldBeCalled();
     $product3->setId(Argument::any())->shouldNotBeCalled();
     $product4->setId('my_mongo_id')->shouldBeCalled();
     $normalizer->normalize($product1, 'mongodb_document', ['collection_name' => 'pim_product_collection'])->willReturn(['_id' => 'my_product_1', 'normalized_product_1']);
     $normalizer->normalize($product2, 'mongodb_document', ['collection_name' => 'pim_product_collection'])->willReturn(['_id' => 'my_mongo_id', 'normalized_product_2']);
     $normalizer->normalize($product3, 'mongodb_document', ['collection_name' => 'pim_product_collection'])->willReturn(['_id' => 'my_product_3', 'normalized_product_3']);
     $normalizer->normalize($product4, 'mongodb_document', ['collection_name' => 'pim_product_collection'])->willReturn(['_id' => 'my_mongo_id', 'normalized_product_4']);
     $collection->batchInsert([['_id' => 'my_mongo_id', 'normalized_product_2'], ['_id' => 'my_mongo_id', 'normalized_product_4']])->shouldBeCalled();
     $collection->update(['_id' => 'my_product_1'], ['_id' => 'my_product_1', 'normalized_product_1'])->shouldBeCalled();
     $collection->update(['_id' => 'my_product_3'], ['_id' => 'my_product_3', 'normalized_product_3'])->shouldBeCalled();
     $pendingPersister->persistPendingVersions([$product1, $product2, $product3, $product4])->shouldBeCalled();
     $eventDispatcher->dispatch('pim_base_connector.direct_to_db_writer.pre_insert', Argument::any())->shouldBeCalled();
     $eventDispatcher->dispatch('pim_base_connector.direct_to_db_writer.pre_update', Argument::any())->shouldBeCalled();
     $eventDispatcher->dispatch('pim_base_connector.direct_to_db_writer.post_insert', Argument::any())->shouldBeCalled();
     $eventDispatcher->dispatch('pim_base_connector.direct_to_db_writer.post_update', Argument::any())->shouldBeCalled();
     $documentManager->clear()->shouldBeCalled();
     $this->write([$product1, $product2, $product3, $product4]);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:26,代码来源:ProductWriterSpec.php

示例3: use

 function it_normalizes_groups($normalizer, $structureVersionProvider, $versionManager, $versionNormalizer, $localizedConverter, GroupInterface $tshirt, GroupTypeInterface $groupType, Version $oldestLog, Version $newestLog, ArrayCollection $products, ProductInterface $product, \ArrayIterator $productsIterator)
 {
     $options = ['decimal_separator' => ',', 'date_format' => 'dd/MM/yyyy'];
     $tshirt->getType()->willReturn($groupType);
     $groupType->isVariant()->willReturn(true);
     $variantNormalized = ['code' => 'my_variant', 'axis' => ['color', 'size'], 'type' => 'variant', 'values' => ['number' => ['data' => 12.5, 'locale' => null, 'scope' => null], 'metric' => ['data' => 12.5, 'locale' => null, 'scope' => null], 'prices' => ['data' => 12.5, 'locale' => null, 'scope' => null], 'date' => ['data' => '2015-01-31', 'locale' => null, 'scope' => null]]];
     $valuesLocalized = ['number' => ['data' => '12,5000', 'locale' => null, 'scope' => null], 'metric' => ['data' => '12,5000', 'locale' => null, 'scope' => null], 'prices' => ['data' => '12,50', 'locale' => null, 'scope' => null], 'date' => ['data' => '31/01/2015', 'locale' => null, 'scope' => null]];
     $normalizer->normalize($tshirt, 'json', $options)->willReturn($variantNormalized);
     $localizedConverter->convertToLocalizedFormats($variantNormalized['values'], $options)->willReturn($valuesLocalized);
     $structureVersionProvider->getStructureVersion()->willReturn(1);
     $versionManager->getOldestLogEntry($tshirt)->willReturn($oldestLog);
     $versionManager->getNewestLogEntry($tshirt)->willReturn($newestLog);
     $versionNormalizer->normalize($oldestLog, 'internal_api')->willReturn('normalized_oldest_log');
     $versionNormalizer->normalize($newestLog, 'internal_api')->willReturn('normalized_newest_log');
     $products->getIterator()->willReturn($productsIterator);
     $productsIterator->rewind()->shouldBeCalled();
     $productsCount = 1;
     $productsIterator->valid()->will(function () use(&$productsCount) {
         return $productsCount-- > 0;
     });
     $productsIterator->next()->shouldBeCalled();
     $productsIterator->current()->will(new ReturnPromise([$product]));
     $product->getId()->willReturn(42);
     $tshirt->getId()->willReturn(12);
     $tshirt->getProducts()->willReturn($products);
     $this->normalize($tshirt, 'internal_api', $options)->shouldReturn(['code' => 'my_variant', 'axis' => ['color', 'size'], 'type' => 'variant', 'values' => $valuesLocalized, 'products' => [42], 'meta' => ['id' => 12, 'form' => 'pim-variant-group-edit-form', 'structure_version' => 1, 'model_type' => 'variant_group', 'created' => 'normalized_oldest_log', 'updated' => 'normalized_newest_log']]);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:27,代码来源:GroupNormalizerSpec.php

示例4:

 function it_clears_cache(StepExecution $stepExecution, ProductInterface $product1, ProductInterface $product2)
 {
     $items = [$product1, $product2];
     $product1->getId()->willReturn('45');
     $product2->getId()->willReturn(null);
     $this->setStepExecution($stepExecution);
     $this->write($items);
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:8,代码来源:ProductWriterSpec.php

示例5: incrementCount

 /**
  * @param ProductInterface $product
  */
 protected function incrementCount(ProductInterface $product)
 {
     if ($product->getId()) {
         $this->stepExecution->incrementSummaryInfo('process');
     } else {
         $this->stepExecution->incrementSummaryInfo('create');
     }
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:11,代码来源:ProductWriter.php

示例6:

 function it_clears_cache($stepExecution, ProductInterface $product1, ProductInterface $product2, JobParameters $jobParameters)
 {
     $stepExecution->getJobParameters()->willReturn($jobParameters);
     $jobParameters->get('realTimeVersioning')->willReturn(true);
     $items = [$product1, $product2];
     $product1->getId()->willReturn('45');
     $product2->getId()->willReturn(null);
     $stepExecution->incrementSummaryInfo('create')->shouldBeCalled();
     $stepExecution->incrementSummaryInfo('process')->shouldBeCalled();
     $this->write($items);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:11,代码来源:ProductWriterSpec.php

示例7:

 function it_find_previous_and_next_products($productRepository, SequentialEdit $sequentialEdit, ProductInterface $product, ProductInterface $previous, ProductInterface $next)
 {
     $sequentialEdit->getObjectSet()->willReturn([1, 6, 5, 2]);
     $sequentialEdit->countObjectSet()->willReturn(4);
     $product->getId()->willReturn(5);
     $productRepository->findOneByWithValues(6)->willReturn($previous);
     $productRepository->findOneByWithValues(2)->willReturn($next);
     $sequentialEdit->setCurrent($product)->shouldBeCalled();
     $sequentialEdit->setPrevious($previous)->shouldBeCalled();
     $sequentialEdit->setNext($next)->shouldBeCalled();
     $this->findWrap($sequentialEdit, $product);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:12,代码来源:SequentialEditManagerSpec.php

示例8: Version

 function it_builds_pending_versions_for_a_given_entity(ProductInterface $product, $builder, $versionRepository)
 {
     $product->getId()->willReturn(1);
     $pending1 = new Version('Product', 1, 'julia');
     $pending1->setChangeset(['foo' => 'bar']);
     $pending2 = new Version('Product', 1, 'julia');
     $pending2->setChangeset(['foo' => 'fubar']);
     $versionRepository->findBy(Argument::cetera())->willReturn([$pending1, $pending2]);
     $builder->buildPendingVersion($pending1, null)->willReturn($pending1)->shouldBeCalled();
     $builder->buildPendingVersion($pending2, $pending1)->willReturn($pending2)->shouldBeCalled();
     $versions = $this->buildPendingVersions($product);
     $versions->shouldHaveCount(2);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:13,代码来源:VersionManagerSpec.php

示例9:

 function it_creates_pending_version($versionFactory, ProductInterface $product, Version $pending)
 {
     $product->getId()->willReturn(1);
     $versionFactory->create(Argument::Any(), 1, 'baz', null)->willReturn($pending);
     $pending->getChangeset()->willReturn($pending);
     $pending->setChangeset([])->willReturn($pending);
     $pending->getAuthor()->willReturn('baz');
     $pending->isPending()->willReturn(true);
     $version = $this->createPendingVersion($product, 'baz', []);
     $version->shouldBeAnInstanceOf('Pim\\Bundle\\VersioningBundle\\Model\\Version');
     $version->getAuthor()->shouldReturn('baz');
     $version->isPending()->shouldReturn(true);
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:13,代码来源:VersionBuilderSpec.php

示例10:

 function it_applies_a_filter_on_product_when_its_in_an_expected_association(FilterDatasourceAdapterInterface $datasource, $utility, QueryBuilder $qb, $extractor, $assocRepository, AssociationTypeInterface $assocType, AbstractAssociation $association, ProductInterface $productOwner, ProductInterface $productAssociatedOne, ProductInterface $productAssociatedTwo, $productRepository)
 {
     $extractor->getDatagridParameter('_parameters', [])->willReturn([]);
     $extractor->getDatagridParameter('associationType')->willReturn(1);
     $assocRepository->findOneBy(Argument::any())->willReturn($assocType);
     $extractor->getDatagridParameter('product')->willReturn(11);
     $productRepository->findOneByWithValues(11)->willReturn($productOwner);
     $productOwner->getAssociationForType($assocType)->willReturn($association);
     $association->getProducts()->willReturn([$productAssociatedOne, $productAssociatedTwo]);
     $productAssociatedOne->getId()->willReturn(12);
     $productAssociatedTwo->getId()->willReturn(13);
     $utility->applyFilter($datasource, 'id', 'IN', [12, 13])->shouldBeCalled();
     $this->apply($datasource, ['type' => null, 'value' => 1]);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:14,代码来源:IsAssociatedFilterSpec.php

示例11: Association

 function it_massively_insert_and_update_objects($bulkSaver, $bulkDetacher, $stepExecution, ProductInterface $product1, ProductInterface $product2, AssociationInterface $association2)
 {
     $bulkSaver->saveAll([$product1, $product2]);
     $bulkDetacher->detachAll([$product1, $product2]);
     $product1->getId()->willReturn(null);
     $association1 = new Association();
     $product1->getAssociations()->willReturn(new ArrayCollection([$association1]));
     $stepExecution->incrementSummaryInfo('process')->shouldBeCalled();
     $product2->getId()->willReturn(42);
     $association2->getId()->willReturn(1);
     $product2->getAssociations()->willReturn(new ArrayCollection([$association2]));
     $stepExecution->incrementSummaryInfo('process')->shouldBeCalled();
     $this->write([$product1, $product2]);
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:14,代码来源:ProductAssociationWriterSpec.php

示例12: getRequiredAttributeCodes

 /**
  * Returns the required attribute codes for a product
  *
  * @param ProductInterface $product
  *
  * @return array
  */
 public function getRequiredAttributeCodes(ProductInterface $product)
 {
     $codes = [];
     if ($product->getFamily()) {
         $codes = $this->getFamilyAttributeCodes($product->getFamily());
     }
     foreach ($product->getGroups() as $group) {
         $codes = array_merge($codes, $this->getGroupAttributeCodes($group));
     }
     if ($product->getId()) {
         foreach ($product->getValues() as $value) {
             $codes[] = $value->getAttribute()->getCode();
         }
     }
     return array_unique($codes);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:23,代码来源:AttributeCache.php

示例13:

 function it_normalizes_an_association_with_products_and_groups($mongoFactory, Association $assoc, AssociationTypeInterface $assocType, \MongoId $mongoId, \MongoDBRef $ownerRef, ProductInterface $product1, \MongoDBRef $product1Ref, ProductInterface $product2, \MongoDBRef $product2Ref, GroupInterface $group1, GroupInterface $group2)
 {
     $assocType->getId()->willReturn(8);
     $assoc->getAssociationType()->willReturn($assocType);
     $context = ['_id' => '1234abc', 'collection_name' => 'product'];
     $mongoFactory->createMongoId()->willReturn($mongoId);
     $mongoFactory->createMongoDBRef('product', '1234abc')->willReturn($ownerRef);
     $mongoFactory->createMongoDBRef('product', 'product1')->willReturn($product1Ref);
     $mongoFactory->createMongoDBRef('product', 'product2')->willReturn($product2Ref);
     $product1->getId()->willReturn('product1');
     $product2->getId()->willReturn('product2');
     $assoc->getProducts()->willReturn([$product1, $product2]);
     $group1->getId()->willReturn(1);
     $group2->getId()->willReturn(2);
     $assoc->getGroups()->willReturn([$group1, $group2]);
     $this->normalize($assoc, 'mongodb_document', $context)->shouldReturn(['_id' => $mongoId, 'associationType' => 8, 'owner' => $ownerRef, 'products' => [$product1Ref, $product2Ref], 'groupIds' => [1, 2]]);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:17,代码来源:AssociationNormalizerSpec.php

示例14: ConstraintViolationList

 function it_does_not_set_values_when_attribute_is_not_editable($validator, $productUpdater, $productDetacher, $productRepository, ProductInterface $product, ProductValueInterface $productValue, StepExecution $stepExecution, JobExecution $jobExecution, JobParameters $jobParameters)
 {
     $this->setStepExecution($stepExecution);
     $product->getIdentifier()->shouldBeCalled()->willReturn($productValue);
     $product->getId()->willReturn(10);
     $productValue->getData()->shouldBeCalled();
     $stepExecution->getJobParameters()->willReturn($jobParameters);
     $jobParameters->get('filters')->willReturn([]);
     $jobParameters->get('actions')->willReturn(['normalized_values' => json_encode(['categories' => [['scope' => null, 'locale' => null, 'data' => ['office', 'bedroom']]]]), 'ui_locale' => 'en_US', 'attribute_locale' => 'en_US', 'attribute_channel' => null]);
     $stepExecution->getJobExecution()->willReturn($jobExecution);
     $stepExecution->incrementSummaryInfo('skipped_products')->shouldBeCalled();
     $stepExecution->addWarning('pim_enrich.mass_edit_action.edit-common-attributes.message.no_valid_attribute', [], Argument::any())->shouldBeCalled();
     $productDetacher->detach($product)->shouldBeCalled();
     $violations = new ConstraintViolationList([]);
     $validator->validate($product)->willReturn($violations);
     $productRepository->hasAttributeInFamily(10, 'categories')->shouldBeCalled()->willReturn(true);
     $productRepository->hasAttributeInVariantGroup(10, 'categories')->shouldBeCalled()->willReturn(true);
     $productUpdater->update($product, Argument::any())->shouldNotBeCalled();
     $this->process($product)->shouldReturn(null);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:20,代码来源:EditCommonAttributesProcessorSpec.php

示例15: transform

 /**
  * @param array                 $result
  * @param string                $associationTypeId
  * @param ProductInterface|null $product
  *
  * @return array
  */
 public function transform(array $result, $associationTypeId, ProductInterface $product = null)
 {
     if ($product) {
         $associationTypeId = (int) $associationTypeId;
         $result['is_associated'] = false;
         $currentAssociation = $product->getAssociations()->filter(function ($association) use($associationTypeId) {
             return $association->getAssociationType()->getId() === $associationTypeId;
         })->first();
         if ($currentAssociation) {
             $associatedIds = $currentAssociation->getProducts()->map(function ($product) {
                 return $product->getId();
             })->toArray();
             if (in_array($result['id'], $associatedIds)) {
                 $result['is_associated'] = true;
             }
         }
         $result['is_checked'] = $result['is_associated'];
     }
     return $result;
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:27,代码来源:AssociationTransformer.php


注:本文中的Pim\Component\Catalog\Model\ProductInterface::getId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。