【问题标题】:Re-index just programmatically changed products with Magento使用 Magento 重新索引以编程方式更改的产品
【发布时间】:2015-12-11 22:57:02
【问题描述】:

我的 Magento 商店中有超过 130.000 种产品。即使我安装了Dn'D Patch Index URL(顺便节省了很多时间,例如:重新索引只需 10 分钟而不是大约 4 小时),通过 Magento 后端接口重新索引所有内容需要花费大量时间我只是通过我的 PHP 文件添加或更改两个产品。

是否可以仅为添加/更改的产品重新索引所有内容(搜索、价格、库存等)?我使用Magmi - DataPump 工具添加/更改它们。我的 PHP 代码如下所示:

$in=array();
$in[]= 'magmi';
$in[]= 'magmi/inc';
$in[]= 'magmi/integration/inc';
$in[]= 'magmi/engines';
$inpath="";
foreach ($in as $i){
    $inpath .= $i .':';
}
$inpath .= '.';
set_include_path($inpath);

require_once("magmi_datapump.php");    // call Datapump

$dp=Magmi_DataPumpFactory::getDataPumpInstance("productimport");
$dp->beginImportSession("default","create");        // default- name of profile ,  create - we want to create and update items

$row = 0;
$handle = fopen("data.csv", "r");
while (($item = fgetcsv($handle, 1000, ",")) !== FALSE) {
    $row++;
    if($row > 0 && $row < 135000){
    $newProductData = array(
            'name'          => (string) $item[1]." ".$item[3],        // name
            'sku'           => (string) $item[1],        // sku     
            'price'         => (real) $item[4],             // price
            'store'         => 'admin',            
            'description'   => (string) $item[2]."\n".$item[3]."\nHerstellerteilenummer: ".$item[1],        // full description
            'short_description' => (string) $item[2]."\n".$item[3]."\nHerstellerteilenummer: ".$item[1],    // short description
            'category_ids'    => '4',                // ID of categories
            'tax_class_id'  => '1',                    // tax class id (check your ids)
            'manufacturer'    => (string) $item[2],        // manufacturer
            'attribute_set' => 'Default',
            'weight'        => (string) "0",
            'use_config_manage_stock'   => 0
    );

    $newProductData['image']='+'.(string) '/media/catalog/product/placeholder/high/'.$item[2].'.png';        // + show picture, - dont show picture
    $newProductData['small_image']='+'.(string) '/media/catalog/product/placeholder/small/'.$item[2].'.png';            // small img
    $newProductData['thumbnail']='+'.(string) '/media/catalog/product/placeholder/thumb/'.$item[2].'.png';            // thumbnail
    $dp->ingest($newProductData);
    print_r($newProductData);
    echo "PRODUCT NR: " . $row;
    echo '' . ' mem:'.memory_get_usage() .  " ... Done! <br />\n";            //memory usage check
    $newProductData=null;    //clear memory
    unset($newProductData); //clear memory
    }
}

unset($item);

$dp->endImportSession();

【问题讨论】:

    标签: php mysql magento indexing magmi


    【解决方案1】:

    “重新索引”是指在表上重新创建 MySQL 索引吗?如果是这样,则无需这样做。索引是动态维护的。

    【讨论】:

    • 但是当我添加产品时,它们在搜索中不可见,并且当我更改产品价格时,这些更改仅在产品页面本身上可见(例如,不在类别页面上)。我必须手动重新索引所有内容以使更改可见(或使新产品可见)
    • 请提供SHOW CREATE TABLE
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-11
    • 1970-01-01
    • 2013-04-23
    • 1970-01-01
    相关资源
    最近更新 更多