当前位置: 首页>>代码示例>>PHP>>正文


PHP AttributeGroup::cleanDeadCombinations方法代码示例

本文整理汇总了PHP中AttributeGroup::cleanDeadCombinations方法的典型用法代码示例。如果您正苦于以下问题:PHP AttributeGroup::cleanDeadCombinations方法的具体用法?PHP AttributeGroup::cleanDeadCombinations怎么用?PHP AttributeGroup::cleanDeadCombinations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AttributeGroup的用法示例。


在下文中一共展示了AttributeGroup::cleanDeadCombinations方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: delete

    public function delete()
    {
        if (!$this->hasMultishopEntries() || Shop::getContext() == Shop::CONTEXT_ALL) {
            /* Select children in order to find linked combinations */
            $attribute_ids = Db::getInstance()->executeS('
				SELECT `id_attribute`
				FROM `' . _DB_PREFIX_ . 'attribute`
				WHERE `id_attribute_group` = ' . (int) $this->id);
            if ($attribute_ids === false) {
                return false;
            }
            /* Removing attributes to the found combinations */
            $to_remove = array();
            foreach ($attribute_ids as $attribute) {
                $to_remove[] = (int) $attribute['id_attribute'];
            }
            if (!empty($to_remove) && Db::getInstance()->execute('
				DELETE FROM `' . _DB_PREFIX_ . 'product_attribute_combination`
				WHERE `id_attribute`
					IN (' . implode(', ', $to_remove) . ')') === false) {
                return false;
            }
            /* Remove combinations if they do not possess attributes anymore */
            if (!AttributeGroup::cleanDeadCombinations()) {
                return false;
            }
            /* Also delete related attributes */
            if (count($to_remove)) {
                if (!Db::getInstance()->execute('
				DELETE FROM `' . _DB_PREFIX_ . 'attribute_lang`
				WHERE `id_attribute`	IN (' . implode(',', $to_remove) . ')') || !Db::getInstance()->execute('
				DELETE FROM `' . _DB_PREFIX_ . 'attribute_shop`
				WHERE `id_attribute`	IN (' . implode(',', $to_remove) . ')') || !Db::getInstance()->execute('DELETE FROM `' . _DB_PREFIX_ . 'attribute` WHERE `id_attribute_group` = ' . (int) $this->id)) {
                    return false;
                }
            }
            $this->cleanPositions();
        }
        $return = parent::delete();
        if ($return) {
            Hook::exec('actionAttributeGroupDelete', array('id_attribute_group' => $this->id));
        }
        return $return;
    }
开发者ID:ecssjapan,项目名称:guiding-you-afteropen,代码行数:44,代码来源:AttributeGroup.php


注:本文中的AttributeGroup::cleanDeadCombinations方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。