本文整理汇总了PHP中Pim\Bundle\CatalogBundle\Model\ProductInterface::setId方法的典型用法代码示例。如果您正苦于以下问题:PHP ProductInterface::setId方法的具体用法?PHP ProductInterface::setId怎么用?PHP ProductInterface::setId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pim\Bundle\CatalogBundle\Model\ProductInterface
的用法示例。
在下文中一共展示了ProductInterface::setId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
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]);
}