<?php Variations::main(); class Variations { private static $n = 4; private static $k = 3; private static $arr = array(); private function __construct() { } public static function main() { self::variations(0); } private static function variations($index) { if ($index == self::$k) { self::printArr(); } else { for ($i = 0; $i < self::$n; $i++) { self::$arr[$index] = $i; self::variations($index + 1); } } } private static function printArr() { echo implode(", ", self::$arr); echo "<br />"; }
<?php /** * Created by Kent M. Patrick * Project: BPU * Company: Fingerprints Ltd * Date: 21/09/2016 * Time: 9:58 AM */ require_once 'header.php'; $variations = new Variations(); $form = new Forms(); if (isset($_POST['submit'])) { $variation_ids = array(); if (isset($_GET['c'])) { if (isset($_POST['enable'])) { foreach ($_POST['enable'] as $id => $toggle) { if ($toggle == "on") { array_push($variation_ids, $id); } } } $variations->submit_toggles(implode(";;", $variation_ids)); $html->redirection("collections.php"); } else { if (isset($_GET['p'])) { $collection_id = $_POST['collection_id']; foreach ($_POST['variation_ids'] as $key => $id) { $p_toggles = array(); $option_id = isset($_POST['option_ids']) ? $_POST['option_ids'][$key] : 0; $variation_id = $id;
$result = $proxy->call($sessionId, $variation['vovariationid'], "product_attribute.update", array($attributeToUpdate)); } } public function deleteAttribute() { $proxy = new SoapClient('http://dev.doability.co.uk/api/soap/?wsdl'); $sessionId = $proxy->login('vikas', 'w3sols!@#'); $prepare = $this->conInterspire->prepare("\n SELECT distinct magentoattributeid FROM `isc_product_variation_options` where magentoattributeid!=0 \n limit 100\n "); $prepare->execute(); $variations = $prepare->fetchAll(PDO::FETCH_ASSOC); foreach ($variations as $variation) { $attributeCode = $variation['magentoattributeid']; try { $result = $proxy->call($sessionId, "product_attribute.remove", array($attributeCode)); $prepare = $this->conInterspire->prepare("\n update `isc_product_variation_options` set magentoattributeid=0 where magentoattributeid='" . $attributeCode . "'\n "); $prepare->execute(); } catch (exception $e) { echo $e->getMessage() . ' ' . $attributeCode; $prepare = $this->conInterspire->prepare("\n update `isc_product_variation_options` set magentoattributeid=0 where magentoattributeid='" . $attributeCode . "'\n "); $prepare->execute(); } } } } $obj = new Variations(); //$obj->AddAttributeSets(); // $obj->AddAttributes(); //$obj->AddAttributesToSets(); $obj->AddVariationOptions(); //$obj->deleteAttribute(); //$obj->UpdateAttributes();