Exemplo n.º 1
0
                $catId = $cat->getId();
                break;
            }
        }
        return $catId;
    }
    public function assignProduct($categoryId, $object)
    {
        $products = array();
        foreach ($object['products'] as $sku) {
            $product = Mage::getModel('catalog/product')->loadByAttribute('sku', $sku);
            if (empty($product) || !$product->getId()) {
                continue;
            }
            $products[$product->getId()] = 1;
            //Mage::getModel('Mage_Catalog_Model_Category_Api')->assignProduct($categoryId, $product->getId());
        }
        $category = Mage::getModel('catalog/category')->load($categoryId);
        $category->setPostedProducts($products);
        try {
            $category->save();
        } catch (Exception $e) {
            echo $e->getMessage();
        }
        echo "\n{$object['name']} assigned\n";
    }
}
echo date("\nY-d-m H:i:s") . " - catalog category import start\n";
$imp = new Category_Export();
$imp->load();
echo date("\nY-d-m H:i:s") . " - catalog category import completed\n";
Exemplo n.º 2
0
                join catalog_category_product_synch s on p.category_id = s.live_category_id
                set p.category_id = s.category_id;
            ";
            $this->exec($query);
            $query = "
                drop table if exists catalog_category_product2;
                create table catalog_category_product2 like catalog_category_product;
                insert into catalog_category_product2 select * from catalog_category_product;
            ";
            $this->exec($query);
            $query = "
                delete from catalog_category_product;
                insert into catalog_category_product select * from catalog_category_product_fm3;
            ";
            $this->exec($query);
        }*/
    public function exec($query)
    {
        $connection = $this->connection;
        try {
            $connection->exec($query);
        } catch (Exception $e) {
            echo $query . "\n";
            echo $e->getMessage();
        }
    }
}
echo date("\nY-d-m H:i:s") . " - catalog category import start\n";
$imp = new Category_Export();
$imp->catalog_category_product_synch();
echo date("\nY-d-m H:i:s") . " - catalog category import completed\n";