Exemple #1
0
    foreach ($updates as $update) {
        foreach ($update as $src => $dst) {
            $old = br()->db()->getRow('SELECT * FROM br_nested_set WHERE name = ?', $src);
            $new = br()->db()->getRow('SELECT * FROM br_nested_set WHERE name = ?', $src);
            if ($dst) {
                $dstId = br()->db()->getValue('SELECT id FROM br_nested_set WHERE name = ?', $dst);
            } else {
                $dstId = null;
            }
            $new = array('parent_id' => $dstId);
            br()->log('UPDATE parent_id OF ' . $old['id'] . ' FROM ' . $old['parent_id'] . ' TO ' . $new['parent_id']);
            br()->db()->table('br_nested_set')->update($new, $old['id']);
            $nestedSet->processUpdate($old, $new);
            printTree();
            $nestedSet->verify();
        }
    }
}
updates($nestedSet, $updates);
function deletes($nestedSet, $deletes)
{
    foreach ($deletes as $delete) {
        $row = br()->db()->getRow('SELECT * FROM br_nested_set WHERE name = ?', $delete);
        br()->db()->table('br_nested_set')->remove($row['id']);
        $nestedSet->processDelete($row);
        printTree();
        $nestedSet->verify();
    }
}
deletes($nestedSet, $deletes);
*/
/*
Ação de Edição
*/
if ($acao == 'edit') {
    foreach ($product_sku as $sku) {
        $product_id = Mage::getModel("catalog/product")->getIdBySku($sku);
        updates($valores[$i], $product_id);
        $i++;
    }
}
/*
Exemplo de edit
https://consultoria7.com/alimentacao/functions.php?acao=edit&id=222222&preco=31.00
*/
/*
Ação de Delete
*/
if ($acao == 'delete') {
    foreach ($product_delete as $sku) {
        $product_id = Mage::getModel("catalog/product")->getIdBySku($sku);
        deletes($product_id);
    }
}
/*
Exemplo de delete simples
https://consultoria7.com/alimentacao/functions.php?acao=delete&id=222222
Exemplo de delete composto
https://consultoria7.com/alimentacao/functions.php?acao=delete&id=222222,333333
2015-09-23
*/