本文整理汇总了PHP中Pim\Bundle\CatalogBundle\Model\ProductInterface::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP ProductInterface::getId方法的具体用法?PHP ProductInterface::getId怎么用?PHP ProductInterface::getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pim\Bundle\CatalogBundle\Model\ProductInterface
的用法示例。
在下文中一共展示了ProductInterface::getId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
function it_hydrates_a_result_record(Builder $builder, Query $query, ProductInterface $product, Association $association, AssociationType $associationType, ProductInterface $associatedProduct1, ProductInterface $associatedProduct2, DocumentManager $documentManager, \Doctrine\ODM\MongoDB\Mapping\ClassMetadata $metadata, Collection $collection, ArrayIterator $arrayIterator)
{
$options = ['locale_code' => 'en_US', 'scope_code' => 'print', 'current_group_id' => null, 'attributes_configuration' => [], 'association_type_id' => 1, 'current_product' => $product];
$builder->getQuery()->willReturn($query);
$builder->hydrate(false)->willReturn($builder);
$associatedProduct1->getId()->willReturn('550ae6b98ead0ed7778b46bb');
$associatedProduct2->getId()->willReturn('550ae6b98abd0ec8778b46bb');
$product->getAssociations()->willReturn([$association]);
$association->getAssociationType()->willReturn($associationType);
$associationType->getId()->willReturn(1);
$association->getProducts()->willReturn([$associatedProduct1, $associatedProduct2]);
$queryDefinition = ['type' => 1, 'sort' => ['normalizedData.is_associated' => -1, '_id' => 1], 'limit' => 10, 'skip' => 0, 'query' => ['_id' => ['$ne' => \MongoId::__set_state(['$id' => '550ae6b98ead0ee8778b46bb'])]], 'newObj' => []];
$query->getQuery()->willReturn($queryDefinition);
$query->getDocumentManager()->willReturn($documentManager);
$documentManager->getDocumentCollection(Argument::any())->willReturn($collection);
$documentManager->getClassMetadata(Argument::any())->willReturn($metadata);
$metadata->getFieldNames()->willReturn(['id', 'created', 'updated', 'locale', 'scope', 'values', 'indexedValues', 'indexedValuesOutdated', 'family', 'familyId', 'categories', 'categoryIds', 'enabled', 'groups', 'groupIds', 'associations', 'completenesses', 'normalizedData']);
$pipeline = [['$match' => ['_id' => ['$ne' => \MongoId::__set_state(['$id' => '550ae6b98ead0ee8778b46bb'])]]], ['$project' => ['id' => 1, 'created' => 1, 'updated' => 1, 'locale' => 1, 'scope' => 1, 'values' => 1, 'indexedValues' => 1, 'indexedValuesOutdated' => 1, 'family' => 1, 'familyId' => 1, 'categories' => 1, 'categoryIds' => 1, 'enabled' => 1, 'groups' => 1, 'groupIds' => 1, 'associations' => 1, 'completenesses' => 1, 'normalizedData' => 1, 'is_associated' => ['$cond' => [['$or' => [['$eq' => ['$_id', \MongoId::__set_state(['$id' => '550ae6b98ead0ed7778b46bb'])]], ['$eq' => ['$_id', \MongoId::__set_state(['$id' => '550ae6b98abd0ec8778b46bb'])]]]], 1, 0]]]], ['$sort' => ['is_associated' => -1]], ['$skip' => 0], ['$limit' => 10]];
$collection->aggregate($pipeline)->willReturn($arrayIterator);
$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];
$arrayIterator->toArray()->willReturn([$fixture]);
$rows = $this->hydrate($builder, $options);
$rows->shouldHaveCount(1);
$firstResult = $rows[0];
$firstResult->shouldBeAnInstanceOf('\\Oro\\Bundle\\DataGridBundle\\Datasource\\ResultRecord');
}
示例2:
function it_normalizes_an_existing_product_into_mongodb_document($mongoFactory, $serializer, ProductInterface $product, \MongoId $mongoId, \MongoDate $mongoDate, Association $assoc1, Association $assoc2, CategoryInterface $category1, CategoryInterface $category2, GroupInterface $group1, GroupInterface $group2, ProductValueInterface $value1, ProductValueInterface $value2, FamilyInterface $family)
{
$mongoFactory->createMongoId('product1')->willReturn($mongoId);
$mongoFactory->createMongoDate()->willReturn($mongoDate);
$family->getId()->willReturn(36);
$category1->getId()->willReturn(12);
$category2->getId()->willReturn(34);
$group1->getId()->willReturn(56);
$group2->getId()->willReturn(78);
$product->getId()->willReturn('product1');
$product->getCreated()->willReturn(null);
$product->getFamily()->willReturn($family);
$product->isEnabled()->willReturn(true);
$product->getGroups()->willReturn([$group1, $group2]);
$product->getCategories()->willReturn([$category1, $category2]);
$product->getAssociations()->willReturn([$assoc1, $assoc2]);
$product->getValues()->willReturn([$value1, $value2]);
$context = ['_id' => $mongoId];
$serializer->normalize($product, 'mongodb_json')->willReturn(['data' => 'data', 'completenesses' => 'completenesses']);
$serializer->normalize($value1, 'mongodb_document', $context)->willReturn('my_value_1');
$serializer->normalize($value2, 'mongodb_document', $context)->willReturn('my_value_2');
$serializer->normalize($assoc1, 'mongodb_document', $context)->willReturn('my_assoc_1');
$serializer->normalize($assoc2, 'mongodb_document', $context)->willReturn('my_assoc_2');
$this->normalize($product, 'mongodb_document')->shouldReturn(['_id' => $mongoId, 'created' => $mongoDate, 'updated' => $mongoDate, 'family' => 36, 'enabled' => true, 'groupIds' => [56, 78], 'categoryIds' => [12, 34], 'associations' => ['my_assoc_1', 'my_assoc_2'], 'values' => ['my_value_1', 'my_value_2'], 'normalizedData' => ['data' => 'data'], 'completenesses' => []]);
}
示例3:
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]);
}
示例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);
}
示例5:
function it_find_previous_and_next_products($productManager, SequentialEdit $sequentialEdit, ProductInterface $product, ProductInterface $previous, ProductInterface $next)
{
$sequentialEdit->getObjectSet()->willReturn([1, 6, 5, 2]);
$sequentialEdit->countObjectSet()->willReturn(4);
$product->getId()->willReturn(5);
$productManager->find(6)->willReturn($previous);
$productManager->find(2)->willReturn($next);
$sequentialEdit->setCurrent($product)->shouldBeCalled();
$sequentialEdit->setPrevious($previous)->shouldBeCalled();
$sequentialEdit->setNext($next)->shouldBeCalled();
$this->findWrap($sequentialEdit, $product);
}
示例6: 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);
}
示例7:
function it_builds_versions_for_versionable_entities($normalizer, ProductInterface $product)
{
$product->getId()->willReturn(1);
$normalizer->normalize($product, 'csv', ['versioning' => true])->willReturn(['bar' => 'baz']);
$version = $this->buildVersion($product, 'foo');
$version->shouldBeAnInstanceOf('Pim\\Bundle\\VersioningBundle\\Model\\Version');
$version->getAuthor()->shouldReturn('foo');
$version->isPending()->shouldReturn(false);
$version->getVersion()->shouldReturn(1);
$version->getResourceId()->shouldReturn(1);
$version->getSnapshot()->shouldReturn(['bar' => 'baz']);
$version->getChangeset()->shouldReturn(['bar' => ['old' => '', 'new' => 'baz']]);
}
示例8: updateExport
/**
* Update export date for the given product.
*
* @param ProductInterface $product
* @param JobInstance $jobInstance
* @param string $table
*/
protected function updateExport(ProductInterface $product, JobInstance $jobInstance, $table)
{
$conn = $this->entityManager->getConnection();
$sql = "\n INSERT INTO {$table}\n (product_id, job_instance_id, last_export)\n VALUES (:product_id, :job_instance_id, :last_export)\n ON DUPLICATE KEY UPDATE last_export = :last_export\n ";
$now = new \DateTime('now', new \DateTimeZone('UTC'));
$formattedNow = $now->format('Y-m-d H:i:s');
$productId = $product->getId();
$jobInstanceId = $jobInstance->getId();
$query = $conn->prepare($sql);
$query->bindParam(':last_export', $formattedNow, PDO::PARAM_STR);
$query->bindParam(':product_id', $productId, PDO::PARAM_INT);
$query->bindParam(':job_instance_id', $jobInstanceId, PDO::PARAM_INT);
$query->execute();
}
示例9: 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]);
}
示例10:
function it_applies_a_filter_on_product_when_its_in_an_expected_association(FilterDatasourceAdapterInterface $datasource, $utility, QueryBuilder $qb, $extractor, $assocRepository, ProductManager $productManager, AssociationTypeInterface $assocType, AbstractAssociation $association, ProductInterface $productOwner, ProductInterface $productAssociatedOne, ProductInterface $productAssociatedTwo, $manager)
{
$extractor->getDatagridParameter('_parameters', [])->willReturn([]);
$extractor->getDatagridParameter('associationType')->willReturn(1);
$assocRepository->findOneBy(Argument::any())->willReturn($assocType);
$extractor->getDatagridParameter('product')->willReturn(11);
$manager->find(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]);
}
示例11: getRequiredAttributeCodes
/**
* Returns the required attribute codes for a product
*
* @param ProductInterface $product
*
* @return array
*/
public function getRequiredAttributeCodes(ProductInterface $product)
{
$codes = array();
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);
}
示例12: 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;
});
$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');
}
示例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]]);
}
示例14: 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;
}
示例15: getMatchingProducts
/**
* Get matching products
*
* @param GroupInterface $variantGroup the variant group
* @param ProductInterface $entity the product
* @param array $criteria query criterias
*
* @return ProductInterface[]
*/
protected function getMatchingProducts(GroupInterface $variantGroup, ProductInterface $entity = null, array $criteria = [])
{
if (!$variantGroup->getId()) {
return [];
}
$matchingProducts = $this->repository->findAllForVariantGroup($variantGroup, $criteria);
if ($entity) {
$matchingProducts = array_filter($matchingProducts, function ($product) use($entity) {
return $product->getId() !== $entity->getId();
});
}
return $matchingProducts;
}