Edit code in magento plug-in for magmi

Closed Posted Jun 19, 2014 Paid on delivery
Closed Paid on delivery

The plugin below will disable product not listed in Magmi's csv file catalog-wide, I want to limit it to only category-wide, that means, if im loading category 1, all other categories wont be affected (disabled). Modify code below to only disable products in categories on csv file

<?php

class Magmi_ItemdisablerPlugin extends Magmi_ItemProcessor

{

protected $datasource_skus = array();

public function getPluginInfo()

{

return array("name"=>"Magmi Magento Item Disabler",

"author"=>"Axel Norvell ([login to view URL])",

"version"=>"1.0.6");

}

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 processItemAfterId(&$item,$params=null)

{

if(isset($item['sku']))

{

$this->datasource_skus[] = $item['sku'];

}

}

public function disableItems()

{

if(count($this->datasource_skus) <= 0)

{

$this->log('No items were found in datasource. Item Disabler will not run.', "info");

return false; /* Nothing to disable */

}

//Setup tables

$ea = $prefix!=""?$prefix."eav_attribute":"eav_attribute";

$eet = $prefix!=""?$prefix."eav_entity_type":"eav_entity_type";

$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 ea.attribute_id FROM $ea ea

LEFT JOIN $eet eet ON ea.entity_type_id = eet.entity_type_id

WHERE ea.attribute_code = 'status'

AND eet.entity_type_code = 'catalog_product'";

$result = $this->selectAll($status_attr_id);

if (count($result) == 1) {

$attribute_id = $result[0]['attribute_id'];

}

unset($result);

//Get all active items

$sql = "SELECT [login to view URL], e.entity_id FROM $cpei i

INNER JOIN $cpe e ON

e.entity_id = i.entity_id

WHERE attribute_id=?

AND [login to view URL] = 1";

$all_magento_items = $this->selectAll($sql, array($attribute_id));

//Setup the magento_skus array for easy processing.

$magento_skus = array();

foreach($all_magento_items as $item)

{

$this->log("{$item['sku']} found in Mage", "info");

$magento_skus[$item['sku']] = $item['entity_id'];

}

//process the array, move anything thats in the datasource.

foreach($this->datasource_skus 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 [login to view URL] = 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");

}

}

}

Magento PHP SQL

Project ID: #6090568

About the project

11 proposals Remote project Active Jul 26, 2014

11 freelancers are bidding on average $132 for this job

AndrwProjects

Hi slgarza. I worked with Magmi and understand your requirement.

$44 USD in 3 days
(298 Reviews)
7.1
VnBestSolutions

Dear Sir, We claim to get it done perfectly for you EXACTLY in the way you want it - Kindly give we a chance and we will prove myself - Ready to prove our words, let's get it done right away and I mean RIGHT AWAY !! More

$126 USD in 3 days
(211 Reviews)
6.9
etechnodroid1515

Dear Project Owner, Hope you are doing great!! First & foremost, Thanks for submitted this job :) I am ready to start working on this project right away. Please ping at freelancer messenger, ready to help you i More

$54 USD in 0 days
(172 Reviews)
6.7
OBog

Hi! My name is Olga I'm project coordinator at 4 DCode- 5 years experienced team which specialised in Magento solutions. We also develop and customized Magento modules and CMS based web-resources. We can disable pr More

$54 USD in 1 day
(22 Reviews)
5.7