Closed

Edit code in magento plug-in for magmi

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 ([url removed, login to view])",

"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 [url removed, login to view], e.entity_id FROM $cpei i

INNER JOIN $cpe e ON

e.entity_id = i.entity_id

WHERE attribute_id=?

AND [url removed, login to view] = 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 [url removed, login to view] = 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");

}

}

}

Skills: Magento, PHP, SQL

See more: magento plug, prefix function, loading function in php, setup product catalog with, modify code, mage processing, axel, status code, update status code, magento extends, edit magento products, plugin catalog, php class found, update code sql, cpe, magento update product php, magento catalog items, csv magmi, class log found, magento status

About the Employer:
( 9 reviews ) Monterrey, Mexico

Project ID: #6090568

12 freelancers are bidding on average $124 for this job

ahtsolutions

Hello, We read your project, we can do it. We are a web design, web development company. We are developing outsourcing market and we always try to continue widening the ArrowHiTech reputation on this market and we have More

$206 USD in 2 days
(397 Reviews)
8.8
p4provider

Hello, Here are Magento Experts , please check Our Latest Magento work In PMB For Our Experience and skills Regarding Magento projects and Let me start your work , 1. Easy access on IMs like Gtalk, Skype, Yahoo a More

$105 USD in 1 day
(137 Reviews)
7.7
dinotech

Hello There Greetings of the Day! We have reviewed your requirement and understood it very well. we would like to quote down some sample of our work so that you can have an idea about working proficiency. http: More

$54 USD in 2 days
(109 Reviews)
7.1
AndrwProjects

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

$44 USD in 3 days
(193 Reviews)
6.5
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
(81 Reviews)
6.0
zyeloncomputech

Hi sir, Thank you for giving opportunity for biding... we have gone through your requirements and we can Edit code in magento plug-in for magmi according to your exact requirements. Please Before Awarding this p More

$315 USD in 6 days
(45 Reviews)
5.8
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
(45 Reviews)
5.5
NextBitseu

Greetings Employer, We could easily able to develop your Extension similar to your needs, we are already expert in that and done with many similar customized Extensions, please check out some of our already devel More

$421 USD in 5 days
(5 Reviews)
5.1
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
(2 Reviews)
2.7
dokam2050

Hi. I'm professional web developer. I have been developing web applications for almost 10 years. I have experiences in developing several web applications in several languages. I'm new here, so I don't want hig More

$30 USD in 1 day
(1 Review)
1.9
ppandare

We are '3stechmind' team of dedicated software professionals developing the web projects for our [login to view URL] area of expertise is design the web site and implement the functional aspects in software technolgies like ph More

$24 USD in 1 day
(2 Reviews)
1.3
HARBRMARIO

this is my first project i will do this project like professional work that will make my reputation. i have talent in this field but i want to prove [login to view URL] way good luck.

$50 USD in 8 days
(0 Reviews)
0.0