本文整理汇总了PHP中Combination::setFieldsToUpdate方法的典型用法代码示例。如果您正苦于以下问题:PHP Combination::setFieldsToUpdate方法的具体用法?PHP Combination::setFieldsToUpdate怎么用?PHP Combination::setFieldsToUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Combination
的用法示例。
在下文中一共展示了Combination::setFieldsToUpdate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateAttribute
public function updateAttribute($id_product_attribute, $wholesale_price, $price, $weight, $unit, $ecotax, $id_images, $reference, $ean13, $default, $location = null, $upc = null, $minimal_quantity = null, $available_date = null, $update_all_fields = true, array $id_shop_list = array())
{
$combination = new Combination($id_product_attribute);
if (!$update_all_fields) {
$combination->setFieldsToUpdate(array('price' => !is_null($price), 'wholesale_price' => !is_null($wholesale_price), 'ecotax' => !is_null($ecotax), 'weight' => !is_null($weight), 'unit_price_impact' => !is_null($unit), 'default_on' => !is_null($default), 'minimal_quantity' => !is_null($minimal_quantity), 'minimal_quantity_fractional' => !is_null($minimal_quantity), 'available_date' => !is_null($available_date)));
}
$price = str_replace(',', '.', $price);
$weight = str_replace(',', '.', $weight);
$combination->price = (double) $price;
$combination->wholesale_price = (double) $wholesale_price;
$combination->ecotax = (double) $ecotax;
$combination->weight = (double) $weight;
$combination->unit_price_impact = (double) $unit;
$combination->reference = pSQL($reference);
$combination->location = pSQL($location);
$combination->ean13 = pSQL($ean13);
$combination->upc = pSQL($upc);
$combination->default_on = (int) $default;
if ($combination->update_fields['minimal_quantity']) {
$minimal_quantity = str_replace(',', '.', $minimal_quantity);
$this->setMinQty($minimal_quantity, $combination);
}
$combination->available_date = $available_date ? pSQL($available_date) : '0000-00-00';
if (count($id_shop_list)) {
$combination->id_shop_list = $id_shop_list;
}
$combination->save();
if (is_array($id_images) && count($id_images)) {
$combination->setImages($id_images);
}
$id_default_attribute = (int) Product::updateDefaultAttribute($this->id);
if ($id_default_attribute) {
$this->cache_default_attribute = $id_default_attribute;
}
Hook::exec('actionProductAttributeUpdate', array('id_product_attribute' => (int) $id_product_attribute));
Tools::clearColorListCache($this->id);
return true;
}
示例2: updateAttribute
/**
* Update a product attribute
*
* @param int $id_product_attribute Product attribute id
* @param float $wholesale_price Wholesale price
* @param float $price Additional price
* @param float $weight Additional weight
* @param float $unit
* @param float $ecotax Additional ecotax
* @param int $id_image Image id
* @param string $reference Reference
* @param string $ean13 Ean-13 barcode
* @param int $default Default On
* @param string $upc Upc barcode
* @param string $minimal_quantity Minimal quantity
* @return array Update result
*/
public function updateAttribute($id_product_attribute, $wholesale_price, $price, $weight, $unit, $ecotax, $id_images, $reference, $ean13, $default, $location = null, $upc = null, $minimal_quantity = null, $available_date = null, $update_all_fields = true, array $id_shop_list = array())
{
$combination = new Combination($id_product_attribute);
if (!$update_all_fields) {
$combination->setFieldsToUpdate(array('price' => !is_null($price), 'wholesale_price' => !is_null($wholesale_price), 'ecotax' => !is_null($ecotax), 'weight' => !is_null($weight), 'unit_price_impact' => !is_null($unit), 'default_on' => !is_null($default), 'minimal_quantity' => !is_null($minimal_quantity), 'available_date' => !is_null($available_date)));
}
$price = str_replace(',', '.', $price);
$weight = str_replace(',', '.', $weight);
$combination->price = (double) $price;
$combination->wholesale_price = (double) $wholesale_price;
$combination->ecotax = (double) $ecotax;
$combination->weight = (double) $weight;
$combination->unit_price_impact = (double) $unit;
$combination->reference = pSQL($reference);
$combination->location = pSQL($location);
$combination->ean13 = pSQL($ean13);
$combination->upc = pSQL($upc);
$combination->default_on = (int) $default;
$combination->minimal_quantity = (int) $minimal_quantity;
$combination->available_date = $available_date ? pSQL($available_date) : '0000-00-00';
if (count($id_shop_list)) {
$combination->id_shop_list = $id_shop_list;
}
$combination->save();
if (is_array($id_images) && count($id_images)) {
$combination->setImages($id_images);
}
$id_default_attribute = (int) Product::updateDefaultAttribute($this->id);
if ($id_default_attribute) {
$this->cache_default_attribute = $id_default_attribute;
}
// Sync stock Reference, EAN13 and UPC for this attribute
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && StockAvailable::dependsOnStock($this->id, Context::getContext()->shop->id)) {
Db::getInstance()->update('stock', array('reference' => pSQL($reference), 'ean13' => pSQL($ean13), 'upc' => pSQL($upc)), 'id_product = ' . $this->id . ' AND id_product_attribute = ' . (int) $id_product_attribute);
}
Hook::exec('actionProductAttributeUpdate', array('id_product_attribute' => (int) $id_product_attribute));
Tools::clearColorListCache($this->id);
return true;
}