本文整理汇总了PHP中Combination::getColorsAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP Combination::getColorsAttributes方法的具体用法?PHP Combination::getColorsAttributes怎么用?PHP Combination::getColorsAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Combination
的用法示例。
在下文中一共展示了Combination::getColorsAttributes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postSave
/**
* Upgrades total_quantity_available after having saved
* @see StockAvailableCore::update()
* @see StockAvailableCore::add()
*/
public function postSave()
{
if ($this->id_product_attribute == 0) {
return true;
}
$id_shop = Shop::getContext() != Shop::CONTEXT_GROUP ? $this->id_shop : null;
if (!Configuration::get('PS_DISP_UNAVAILABLE_ATTR')) {
$combination = new Combination((int) $this->id_product_attribute);
if ($colors = $combination->getColorsAttributes()) {
$product = new Product((int) $this->id_product);
foreach ($colors as $color) {
if ($product->isColorUnavailable((int) $color['id_attribute'], (int) $this->id_shop)) {
Tools::clearColorListCache($product->id);
break;
}
}
}
}
$total_quantity = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT SUM(quantity) as quantity
FROM ' . _DB_PREFIX_ . 'stock_available
WHERE id_product = ' . (int) $this->id_product . '
AND id_product_attribute <> 0 ' . StockAvailable::addSqlShopRestriction(null, $id_shop));
$this->setQuantity($this->id_product, 0, $total_quantity, $id_shop);
return true;
}
示例2: postSave
/**
* Upgrades total_quantity_available after having saved
* @see StockAvailableCore::update()
* @see StockAvailableCore::add()
*/
public function postSave()
{
if ($this->id_product_attribute == 0) {
return true;
}
$id_shop = Shop::getContext() != Shop::CONTEXT_GROUP ? $this->id_shop : null;
if (!Configuration::get('PS_DISP_UNAVAILABLE_ATTR')) {
$combination = new Combination((int) $this->id_product_attribute);
if ($colors = $combination->getColorsAttributes()) {
$product = new Product((int) $this->id_product);
foreach ($colors as $color) {
if ($product->isColorUnavailable((int) $color['id_attribute'], (int) $this->id_shop)) {
// Change template dir if called from the BackOffice
$current_template_dir = Context::getContext()->smarty->getTemplateDir();
Context::getContext()->smarty->setTemplateDir(_PS_THEME_DIR_ . 'tpl');
Tools::clearCache(null, 'product-list-colors.tpl', Product::getColorsListCacheId((int) $product->id));
Context::getContext()->smarty->setTemplateDir($current_template_dir);
break;
}
}
}
}
$total_quantity = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT SUM(quantity) as quantity
FROM ' . _DB_PREFIX_ . 'stock_available
WHERE id_product = ' . (int) $this->id_product . '
AND id_product_attribute <> 0 ' . StockAvailable::addSqlShopRestriction(null, $id_shop));
$this->setQuantity($this->id_product, 0, $total_quantity, $id_shop);
return true;
}