added duplicate store
This commit is contained in:
@@ -1294,4 +1294,36 @@ class AdminController extends Controller
|
||||
'message' => "successfully updated."
|
||||
));
|
||||
}
|
||||
|
||||
public function duplicateStore($storeid, $newStore)
|
||||
{
|
||||
$AdminModel = new AdminModel;
|
||||
$newStoreId = $newStore;
|
||||
$storeProducts = $AdminModel->selectTeamstoreProducts('TeamStoreId', $storeid);
|
||||
|
||||
foreach($storeProducts as $product) {
|
||||
|
||||
$productId = $product->Id;
|
||||
unset($product->Id);
|
||||
unset($product->DateCreated);
|
||||
|
||||
$product->ProductURL = str_slug($product->ProductURL . '-copy');
|
||||
$product->TeamStoreId = $newStoreId;
|
||||
|
||||
$product = json_decode(json_encode($product), true);
|
||||
var_dump($product);
|
||||
|
||||
$response = $AdminModel->insertStoreItem($product);
|
||||
var_dump($response);
|
||||
|
||||
$productThumbnails = $AdminModel->selectProductThumbnail($productId);
|
||||
foreach($productThumbnails as $productThumbnail) {
|
||||
unset($productThumbnail->Id);
|
||||
unset($productThumbnail->DateCreated);
|
||||
$productThumbnail->ProductId = $response['lastId'];
|
||||
$AdminModel->insertProductThumbnails(json_decode(json_encode($productThumbnail), true));
|
||||
var_dump($productThumbnail);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user