本文整理汇总了PHP中Product::getID方法的典型用法代码示例。如果您正苦于以下问题:PHP Product::getID方法的具体用法?PHP Product::getID怎么用?PHP Product::getID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Product
的用法示例。
在下文中一共展示了Product::getID方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getThemeByProduct
public static function getThemeByProduct(Product $product)
{
$c = eq(__CLASS__ . '.productID', $product->getID());
$c->addOr(self::getCategoryCondition($product->getCategory()));
$f = select($c);
$f->setOrder(new ARExpressionHandle('CategoryPresentation.productID=' . $product->getID()), 'DESC');
self::setCategoryOrder($product->getCategory(), $f);
// check if a theme is defined for this product particularly
$set = ActiveRecordModel::getRecordSet(__CLASS__, $f, array('Category'));
return self::getInheritedConfig($set);
}
示例2: testCreateNewGroup
public function testCreateNewGroup()
{
$group = ProductFileGroup::getNewInstance($this->product);
$group->setValueByLang('name', 'en', 'TEST_GROUP');
$group->save();
$group->reload(array('Product'));
$name = $group->name->get();
$this->assertEqual($name['en'], 'TEST_GROUP');
$this->assertEqual($this->product->getID(), $group->product->get()->getID());
$this->assertTrue($this->product === $group->product->get());
}
示例3: setUp
public function setUp()
{
parent::setUp();
// create a product without attributes
$this->product = Product::getNewInstance($this->category, 'test');
$this->product->setValueByLang("name", "en", "TEST_PRODUCT");
$this->product->save();
$this->productAutoIncrementNumber = $this->product->getID();
for ($k = 1; $k < 4; $k++) {
$currency = Currency::getNewInstance($k . 'zz');
$currency->save();
}
}
示例4: setUp
public function setUp()
{
parent::setUp();
$this->specField = SpecField::getNewInstance($this->rootCategory, SpecField::DATATYPE_TEXT, SpecField::TYPE_TEXT_SELECTOR);
$this->specField->save();
$this->specFieldAutoIncrementNumber = $this->specField->getID();
$specFieldValue = SpecFieldValue::getNewInstance($this->specField);
$specFieldValue->save();
$this->specFieldValueAutoIncrementNumber = $specFieldValue->getID();
$this->product = Product::getNewInstance($this->rootCategory, 'test');
$this->product->save();
$this->productAutoIncrementNumber = $this->product->getID();
}
示例5: getProductGroupsFilter
private static function getProductGroupsFilter(Product $product)
{
$filter = new ARSelectFilter();
$filter->setOrder(new ARFieldHandle(__CLASS__, "position"), 'ASC');
$filter->setCondition(new EqualsCond(new ARFieldHandle(__CLASS__, "productID"), $product->getID()));
return $filter;
}
示例6: __construct
public function __construct(Product $product, $prices = null, LiveCart $application)
{
$this->product = $product;
$this->application = $application;
if (is_null($prices) && $product->getID()) {
$prices = $product->getRelatedRecordSet("ProductPrice", new ARSelectFilter());
}
if ($prices instanceof ARSet) {
foreach ($prices as $price) {
$this->setPrice($price);
}
} else {
if (is_array($prices)) {
foreach ($prices as $id => $price) {
if (array_key_exists('ID', $price)) {
$this->prices[$id] = ProductPrice::getInstance($product, Currency::getInstanceById($id));
} else {
$this->prices[$id] = ProductPrice::getNewInstance($product, Currency::getInstanceById($id));
}
$this->prices[$id]->price->set($price['price']);
$this->prices[$id]->listPrice->set($price['listPrice']);
$this->prices[$id]->serializedRules->set(serialize($price['serializedRules']));
$this->prices[$id]->resetModifiedStatus();
}
}
}
}
示例7: setUp
public function setUp()
{
parent::setUp();
// Create some product
$this->product1 = Product::getNewInstance($this->rootCategory, 'test');
$this->product1->save();
$this->productAutoIncrementNumber = $this->product1->getID();
// Create second product
$this->product2 = Product::getNewInstance($this->rootCategory, 'test');
$this->product2->save();
// create new group
$this->group = ProductRelationshipGroup::getNewInstance($this->product1, ProductRelationship::TYPE_CROSS);
$this->group->position->set(5);
$this->group->save();
$this->groupAutoIncrementNumber = $this->group->getID();
}
示例8: getProductGroupsFilter
private static function getProductGroupsFilter(Product $product, $type)
{
$filter = new ARSelectFilter();
$filter->setOrder(new ARFieldHandle("ProductRelationshipGroup", "position"), 'ASC');
$filter->setCondition(new EqualsCond(new ARFieldHandle("ProductRelationshipGroup", "productID"), $product->getID()));
$filter->mergeCondition(new EqualsCond(new ARFieldHandle("ProductRelationshipGroup", "type"), $type));
return $filter;
}
示例9: testClone
public function testClone()
{
$image = ActiveRecordModel::getNewInstance('ProductImage');
$image->product->set($this->product);
$image->save();
$this->assertSame($image, $this->product->defaultImage->get());
$numField = SpecField::getNewInstance($this->productCategory, SpecField::DATATYPE_NUMBERS, SpecField::TYPE_NUMBERS_SIMPLE);
$numField->save();
$this->product->setAttributeValue($numField, 100);
$this->product->save();
$option = ProductOption::getNewInstance($this->product);
$option->type->set(ProductOption::TYPE_SELECT);
$option->setValueByLang('name', 'en', 'test');
$option->save();
$related = Product::getNewInstance($this->productCategory, 'related');
$related->save();
$relGroup = ProductRelationshipGroup::getNewInstance($this->product, ProductRelationship::TYPE_CROSS);
$relGroup->save();
$rel = ProductRelationship::getNewInstance($this->product, $related, $relGroup);
$rel->save();
$this->assertEquals(1, $this->product->getRelationships()->size());
$cloned = clone $this->product;
$this->assertEquals(100, $cloned->getSpecification()->getAttribute($numField)->value->get());
$cloned->setAttributeValue($numField, 200);
$cloned->setPrice($this->usd, 80);
$cloned->save();
$this->assertNotEquals($cloned->getID(), $this->product->getID());
ActiveRecordModel::clearPool();
$reloaded = Product::getInstanceByID($cloned->getID(), true);
$reloaded->loadPricing();
$this->assertEquals(80, $reloaded->getPrice($this->usd));
$reloaded->loadSpecification();
$this->assertEquals(200, $reloaded->getSpecification()->getAttribute($numField)->value->get());
// related products
$rel = $reloaded->getRelationships();
$this->assertEquals(1, $rel->size());
$this->assertSame($reloaded, $rel->get(0)->productRelationshipGroup->get()->product->get());
// options
$clonedOpts = ProductOption::getProductOptions($reloaded);
$this->assertEquals(1, $clonedOpts->size());
// image
$this->assertTrue(is_object($reloaded->defaultImage->get()));
$this->assertNotEquals($reloaded->defaultImage->get()->getID(), $this->product->defaultImage->get()->getID());
}
示例10: importProductVariationValue
private function importProductVariationValue(Product $product, $index, $name)
{
$parent = $product->parent->get();
$type = $this->getVariationTypeByIndex($parent, $index);
if (!$type->getID()) {
$type = $this->importVariationType($parent, $index, '');
}
$f = new ARSelectFilter();
$f->mergeCondition(new EqualsCond(MultiLingualObject::getLangSearchHandle(new ARFieldHandle('ProductVariation', 'name'), $this->application->getDefaultLanguageCode()), $name));
$values = $type->getRelatedRecordSet('ProductVariation', $f);
if ($values->size()) {
$variation = $values->get(0);
} else {
$variation = ProductVariation::getNewInstance($type);
$variation->setValueByLang('name', null, $name);
$variation->save();
}
if (!$product->getID()) {
$product->save();
}
$f = new ARDeleteFilter(new EqualsCond(new ARFieldHandle('ProductVariation', 'typeID'), $type->getID()));
$product->deleteRelatedRecordSet('ProductVariationValue', $f, array('ProductVariation'));
ProductVariationValue::getNewInstance($product, $variation)->save();
}
示例11: getRelatedProductsSetFilter
private static function getRelatedProductsSetFilter(Product $product, $type)
{
$filter = new ARSelectFilter();
$filter->joinTable('ProductRelationshipGroup', 'ProductRelationship', 'ID', 'productRelationshipGroupID');
$filter->setOrder(new ARFieldHandle("ProductRelationshipGroup", "position"), 'ASC');
$filter->setOrder(new ARFieldHandle(__CLASS__, "position"), 'ASC');
$filter->setCondition(new EqualsCond(new ARFieldHandle(__CLASS__, "productID"), $product->getID()));
$filter->mergeCOndition(new EqualsCond(new ARFieldHandle(__CLASS__, "type"), $type));
return $filter;
}
示例12: processRecord
protected function processRecord(Product $product)
{
$act = $this->getAction();
$field = $this->getField();
if ('manufacturer' == $act) {
$product->manufacturer->set($this->params['manufacturer']);
} else {
if ('price' == $act) {
$product->setPrice($this->params['baseCurrency'], $this->params['price']);
} else {
if (in_array($act, array('inc_price', 'multi_price', 'div_price'))) {
$actions = array('inc_price' => 'increasePriceByPercent', 'multi_price' => 'multiplyPrice', 'div_price' => 'dividePrice');
$action = $actions[$act];
$pricing = $product->getPricingHandler();
foreach ($this->params['currencies'] as $currency) {
if ($pricing->isPriceSet($currency)) {
$p = $pricing->getPrice($currency);
$p->{$action}($this->params['inc_price_value'], $this->params['inc_quant_price']);
$p->save();
}
}
} else {
if ('inc_stock' == $act) {
$product->stockCount->set($product->stockCount->get() + $this->request->get($act));
} else {
if ('addRelated' == $act) {
$product->addRelatedProduct($this->params['relatedProduct']);
} else {
if ('copy' == $act) {
$cloned = clone $product;
$cloned->category->set($this->params['category']);
$cloned->save();
} else {
if ('addCat' == $act) {
// check if the product is not assigned to this category already
$relation = ActiveRecordModel::getInstanceByIdIfExists('ProductCategory', array('productID' => $product->getID(), 'categoryID' => $this->params['category']->getID()));
if (!$relation->isExistingRecord() && $product->category->get() !== $category) {
$relation->save();
}
} else {
if ('theme' == $act) {
$instance = CategoryPresentation::getInstance($product);
$instance->theme->set($this->params['theme']);
$instance->save();
} else {
if ('shippingClass' == $act) {
$product->shippingClass->set(ActiveRecordModel::getInstanceByIDIfExists('ShippingClass', $this->params['shippingClass'], false));
} else {
if ('taxClass' == $act) {
$product->taxClass->set(ActiveRecordModel::getInstanceByIDIfExists('TaxClass', $this->params['taxClass'], false));
} else {
if (substr($act, 0, 13) == 'set_specField') {
$this->params['request']->remove('manufacturer');
$product->loadRequestData($this->params['request']);
} else {
if (substr($act, 0, 16) == 'remove_specField') {
$this->params['request']->remove('manufacturer');
if ($this->params['field']->isMultiValue->get()) {
// remove only selected multi-select options
$product->loadRequestData($this->params['request']);
} else {
$product->removeAttribute($this->params['field']);
}
} else {
parent::processRecord($product);
}
}
}
}
}
}
}
}
}
}
}
}
}
示例13: contains
public function contains(Product $product)
{
$f = new ARSelectFilter(new EqualsCond(new ARFieldHandle('ProductListItem', 'productID'), $product->getID()));
return $this->getRelatedRecordCount('ProductListItem', $f) > 0;
}
示例14: registerLastViewedProduct
public static function registerLastViewedProduct(Product $product)
{
self::registerLastViewed(array('productID' => $product->getID(), 'instance' => $product));
}
示例15: getItemsByProduct
public function getItemsByProduct(Product $product)
{
$items = array();
foreach ($this->orderedItems as $item) {
if ($item->getProduct()->getID() == $product->getID()) {
$items[] = $item;
}
}
return $items;
}