SHARE
TWEET

Untitled

a guest May 26th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. // старый ID родителя
  4. $criteria = array(
  5.   'parent:IN' => array(7142)  
  6. );
  7.  
  8. $products = $modx->getCollection("msProduct", $criteria);
  9.  
  10. echo count($products)."<br/>";
  11. foreach($products as $product){
  12.     echo $product->get("pagetitle")."<br/>";
  13.     $data = array();
  14.     $data["pattern"] = $product->get("uri");
  15.     // новый ID родителя
  16.     $product->set("parent", 7140);
  17.     $product->save();
  18.     $data["target"] = $product->get("uri");
  19.     $data["context_key"] = "web";
  20.     $data["active"] = 1;
  21.     print_r($data);
  22.     // редирект
  23.     $redirect = $modx->newObject("modRedirect", $data);
  24.     if ($redirect->save() == false){
  25.         echo "ошибка<br/>";
  26.     }
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top