плагины — PHP уведомление Неопределенный индекс для magmi disabler

У меня есть настройка magmi с отключением предметов. И я получил уведомление PHP: неопределенный индекс: ITEM_SID в /home/mywebsite/www/public_html/magmi/plugins/extra/itemprocessors/itemdisabler/magmi_itemdisabler_plugin.php в строке 65

Это мой код для отключения элемента

<?php class Magmi_ItemdisablerPlugin extends Magmi_GeneralImportPlugin {


protected $_dcols=array();
protected $magentoSortableAttributes = array();


public function getPluginInfo()

{
return array("name"=>"Magmi Magento Item Disabler",
"author"=>"RIS",
"version"=>"1.0.0");
}

public function afterImport()
{
$this->log("Running Item Disabler Plugin","info");
$this->disableItems();
return true;
}

public function getPluginParams($params)
{
return array();
}

public function isRunnable()
{
return array(true,"");
}

public function initialize($params)
{
}

public function disableItems()
{

$this->datasource = $this->getDataSource();
$nitems=$this->lookup();


if($nitems>0)
{
$datasource_item_sids = array();
$this->resetSkuStats();

//intialize store id cache
$this->callPlugins("datasources,itemprocessors","startImport");

//initializing item processors
$cols=$this->datasource->getColumnNames();
$this->log(count($cols),"columns");
//$this->callPlugins("itemprocessors","processColumnList",$cols);


//Pack the datasource sids into an array
$i = 0;
while(($item=$this->datasource->getNextRecord())!==false && $i++ <= $nitems)
{
if (isset($item['STYLE_SID']) && $this->isConfigurable($item['ATTR']))
{
array_push($datasource_item_sids, $item['STYLE_SID']);
}
array_push($datasource_item_sids, $item['ITEM_SID']);

if($i == $nitems) {
break;
}
}

if(count($datasource_item_sids) > 0) {

//Convert skus to comma seperated values.
//$datasource_item_sids = "'" . implode("','",$datasource_item_sids) . "'";

//Load in Database Helpers
require_once(realpath(dirname( __FILE__ ) )."/../../../../inc/dbhelper.class.php");
//var_dump($this->_magmiconfig->load()->get("DATABASE","host","localhost"));
$db = new DBHelper();
$host=$this->_magmiconfig->load()->get("DATABASE","host","localhost");
$dbname=$this->_magmiconfig->load()->get("DATABASE","dbname","magento");
$user=$this->_magmiconfig->load()->get("DATABASE","user");
$pass=$this->_magmiconfig->load()->get("DATABASE","password");
$debug=$this->_magmiconfig->load()->get("DATABASE","debug");
$conn=$this->_magmiconfig->load()->get("DATABASE","connectivity","net");
$port=$this->_magmiconfig->load()->get("DATABASE","port","3306");
$socket=$this->_magmiconfig->load()->get("DATABASE","unix_socket");
$prefix=$this->_magmiconfig->load()->get("DATABASE","table_prefix");
$db->initDb($host,$dbname,$user,$pass,$port,$socket,$conn,$debug);

//Setup tables
$ea     = $prefix!=""?$prefix."eav_attribute":"eav_attribute";
$cpe     = $prefix!=""?$prefix."catalog_product_entity":"catalog_product_entity";
$cpei     = $prefix!=""?$prefix."catalog_product_entity_int":"catalog_product_entity_int";

//Get "status" attribute_id
$status_attr_id = "SELECT attribute_id FROM $ea WHERE attribute_code = 'status'";
$result = $db->selectAll($status_attr_id);
if (count($result) == 1) {
$attribute_id = $result[0]['attribute_id'];
}
unset($result);

//Get all active items
$sql = "SELECT e.sku, e.entity_id FROM $cpei i
INNER JOIN $cpe e ON
e.entity_id = i.entity_id
WHERE attribute_id=?
AND i.value = 1";
$all_magento_items = $db->selectAll($sql, array($attribute_id));

//Setup the magento_skus array for easy processing.
$magento_skus = array();
foreach($all_magento_items as $item)
{
$magento_skus[$item['sku']] = $item['entity_id'];
}


//process the array, move anything thats in the datasource.
foreach($datasource_item_sids as $sku)
{
if(isset($magento_skus[$sku]))
{
unset($magento_skus[$sku]);
}
}

if(!empty($magento_skus))
{
foreach($magento_skus as $sku => $id)
{

$this->log("Disabling Item Id $id with SKU: $sku", "info");
$this->update("UPDATE $cpei i
INNER JOIN $cpe e ON
e.entity_id = i.entity_id
SET VALUE = '2'
WHERE attribute_id = ?
AND i.value = 1
AND e.sku=?", array($attribute_id, $sku));
}
}
else
{
//If the Datasource contains all Magento's items.
$this->log('All items present in datasource.  No items to disable.', "info");
}

$db->exitDb();
unset($db);

}

}

}

public function isConfigurable($field) {
$attributes = explode('|',$field);

$conf_attributes = '';

foreach($attributes as $attribut) {
$att = explode(':',$attribut);
if(count($att) != 2) {
return false;
break;

}
if($att[1] == '') {
return false;
break;
}
}

return true;

}

}

Любая идея, как я могу решить это?

0

Решение

Вы можете проверить, установлен ли этот элемент перед его использованием:

while(($item=$this->datasource->getNextRecord())!==false && $i++ <= $nitems)
{
if (isset($item['STYLE_SID']) && $this->isConfigurable($item['ATTR']))
{
array_push($datasource_item_sids, $item['STYLE_SID']);
}
if (isset($item['ITEM_SID']){
array_push($datasource_item_sids, $item['ITEM_SID']);
}
if($i == $nitems) {
break;
}
}
0

Другие решения

Других решений пока нет …

По вопросам рекламы [email protected]