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


PHP Combination::delete方法代码示例

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


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

示例1: delete

 /**
  * @see ObjectModel::delete()
  */
 public function delete()
 {
     if (!$this->hasMultishopEntries() || Shop::getContext() == Shop::CONTEXT_ALL) {
         $result = Db::getInstance()->executeS('SELECT id_product_attribute FROM ' . _DB_PREFIX_ . 'product_attribute_combination WHERE id_attribute = ' . (int) $this->id);
         $products = array();
         foreach ($result as $row) {
             $combination = new Combination($row['id_product_attribute']);
             $newRequest = Db::getInstance()->executeS('SELECT id_product, default_on FROM ' . _DB_PREFIX_ . 'product_attribute WHERE id_product_attribute = ' . (int) $row['id_product_attribute']);
             foreach ($newRequest as $value) {
                 if ($value['default_on'] == 1) {
                     $products[] = $value['id_product'];
                 }
             }
             $combination->delete();
         }
         foreach ($products as $product) {
             $result = Db::getInstance()->executeS('SELECT id_product_attribute FROM ' . _DB_PREFIX_ . 'product_attribute WHERE id_product = ' . (int) $product . ' LIMIT 1');
             foreach ($result as $row) {
                 if (Validate::isLoadedObject($product = new Product((int) $product))) {
                     $product->deleteDefaultAttributes();
                     $product->setDefaultAttribute($row['id_product_attribute']);
                 }
             }
         }
         // Delete associated restrictions on cart rules
         CartRule::cleanProductRuleIntegrity('attributes', $this->id);
         /* Reinitializing position */
         $this->cleanPositions((int) $this->id_attribute_group);
     }
     $return = parent::delete();
     if ($return) {
         Hook::exec('actionAttributeDelete', array('id_attribute' => $this->id));
     }
     return $return;
 }
开发者ID:M03G,项目名称:PrestaShop,代码行数:38,代码来源:Attribute.php

示例2: delete

 public function delete()
 {
     if (!$this->hasMultishopEntries()) {
         $result = Db::getInstance()->executeS('SELECT id_product_attribute FROM ' . _DB_PREFIX_ . 'product_attribute_combination WHERE id_attribute = ' . (int) $this->id);
         foreach ($result as $row) {
             $combination = new Combination($row['id_product_attribute']);
             $combination->delete();
         }
         // Delete associated restrictions on cart rules
         CartRule::cleanProductRuleIntegrity('attributes', $this->id);
         /* Reinitializing position */
         $this->cleanPositions((int) $this->id_attribute_group);
     }
     $return = parent::delete();
     if ($return) {
         Hook::exec('actionAttributeDelete', array('id_attribute' => $this->id));
     }
     return $return;
 }
开发者ID:jicheng17,项目名称:pengwine,代码行数:19,代码来源:Attribute.php

示例3: cleanDeadCombinations

    public static function cleanDeadCombinations()
    {
        $attribute_combinations = Db::getInstance()->executeS('
			SELECT pac.`id_attribute`, pa.`id_product_attribute`
			FROM `' . _DB_PREFIX_ . 'product_attribute` pa
			LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute_combination` pac
				ON (pa.`id_product_attribute` = pac.`id_product_attribute`)
		');
        $to_remove = array();
        foreach ($attribute_combinations as $attribute_combination) {
            if ((int) $attribute_combination['id_attribute'] == 0) {
                $to_remove[] = (int) $attribute_combination['id_product_attribute'];
            }
        }
        $return = true;
        if (!empty($to_remove)) {
            foreach ($to_remove as $remove) {
                $combination = new Combination($remove);
                $return &= $combination->delete();
            }
        }
        return $return;
    }
开发者ID:ecssjapan,项目名称:guiding-you-afteropen,代码行数:23,代码来源:AttributeGroup.php

示例4: setWsCombinations

    /**
     * Webservice setter : set combination ids of current product for association
     *
     * @param $combinations combination ids
     */
    public function setWsCombinations($combinations)
    {
        // No hook exec
        $ids_new = array();
        foreach ($combinations as $combination) {
            $ids_new[] = (int) $combination['id'];
        }
        $ids_orig = array();
        $original = Db::getInstance()->executeS('SELECT pa.`id_product_attribute` as id
			FROM `' . _DB_PREFIX_ . 'product_attribute` pa
			' . Shop::addSqlAssociation('product_attribute', 'pa') . '
			WHERE `id_product` = ' . (int) $this->id);
        if (is_array($original)) {
            foreach ($original as $id) {
                $ids_orig[] = $id['id'];
            }
        }
        $all_ids = array();
        $all = Db::getInstance()->executeS('SELECT pa.`id_product_attribute` as id FROM `' . _DB_PREFIX_ . 'product_attribute` pa ' . Shop::addSqlAssociation('product_attribute', 'pa'));
        if (is_array($all)) {
            foreach ($all as $id) {
                $all_ids[] = $id['id'];
            }
        }
        $to_add = array();
        foreach ($ids_new as $id) {
            if (!in_array($id, $ids_orig)) {
                $to_add[] = $id;
            }
        }
        $to_delete = array();
        foreach ($ids_orig as $id) {
            if (!in_array($id, $ids_new)) {
                $to_delete[] = $id;
            }
        }
        // Delete rows
        if (count($to_delete) > 0) {
            foreach ($to_delete as $id) {
                $combination = new Combination($id);
                $combination->delete();
            }
        }
        foreach ($to_add as $id) {
            // Update id_product if exists else create
            if (in_array($id, $all_ids)) {
                Db::getInstance()->execute('UPDATE `' . _DB_PREFIX_ . 'product_attribute` SET id_product = ' . (int) $this->id . ' WHERE id_product_attribute=' . $id);
            } else {
                Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'product_attribute` (`id_product`) VALUES (' . $this->id . ')');
            }
        }
        return true;
    }
开发者ID:jicheng17,项目名称:vipinsg,代码行数:58,代码来源:Product.php


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