PageRenderTime 40ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/magmi/plugins/base/itemprocessors/productdeleter/productdeleter.php

https://bitbucket.org/jit_bec/shopifine
PHP | 43 lines | 36 code | 4 blank | 3 comment | 3 complexity | 3be722ef2b75699a664ec56aa3566ce3 MD5 | raw file
Possible License(s): LGPL-3.0
  1. <?php
  2. class ProductDeleter extends Magmi_ItemProcessor
  3. {
  4. public function getPluginInfo()
  5. {
  6. return array(
  7. "name" => "Product Deleter",
  8. "author" => "Dweeves",
  9. "version" => "0.0.1",
  10. "url" => "http://sourceforge.net/apps/mediawiki/magmi/index.php?title=Product_Deleter"
  11. );
  12. }
  13. public function getPluginParamNames()
  14. {
  15. return array("PDEL:delsimples");
  16. }
  17. public function processItemAfterId(&$item,$params=null)
  18. {
  19. //get item ids, since we are before id
  20. $pid=$params["product_id"];
  21. if(isset($item["magmi:delete"]) && $item["magmi:delete"]==1)
  22. {
  23. $this->log("DELETING SKU '".$item["sku"]."' =>".$pid,"info");
  24. //delete simple products if flag set
  25. if($this->getParam("PDEL:delsimples",false)==true)
  26. {
  27. $childrensel="SELECT entity_id FROM ".$this->tablename("catalog_product_entity")." as cpe
  28. JOIN ".$this->tablename("catalog_product_super_link")." as cpl ON cpl.parent_id=? AND cpe.entity_id=cpl.product_id";
  29. $sql="DELETE cpe.* FROM ".$this->tablename("catalog_product_entity")." cpe WHERE cpe.entity_id IN (SELECT s1.entity_id FROM ($childrensel) as s1)";
  30. $this->delete($sql,$pid);
  31. }
  32. //delete product (this cascades for all eav & relations)
  33. $sql="DELETE FROM ".$this->tablename("catalog_product_entity")." WHERE entity_id=?";
  34. $this->delete($sql,$pid);
  35. $this->log($sql,"info");
  36. $item=array();
  37. }
  38. }
  39. }