2

Array :-

 foreach ($relatedProducts as $relatedProduct) {
        $_product = $objectManager->create('Magento\Catalog\Model\Product')->load($relatedProduct->getId());
        $skus = $_product->getSku(); //get name
        $array[] = $skus;
    }
$str = serialize($array);
$strenc = urlencode($str);

URL :-

<script>
    function onTryonClick(argument) {
var url = "https://modakatech.com/camweara_vaibhav/index.php?skus=<?php echo $strenc; ?>&lengths=<?php echo $lengths;?>&cat=<?php echo $catlast;?>";
alert(url);
</script>

1 Answer 1

2

You can use this code:

foreach ($relatedProducts as $relatedProduct) {
        $_product = $objectManager->create('Magento\Catalog\Model\Product')->load($relatedProduct->getId());
        $skus = $_product->getSku(); //get name
        $array[] = "sku[]=".$skus;
    }

Now in your script, use this:

<script>
    function onTryonClick(argument) {
var url = "https://modakatech.com/camweara_vaibhav/index.php?<?php echo $implode("&",$array); ?>&lengths=<?php echo $lengths;?>&cat=<?php echo $catlast;?>";
alert(url);
</script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.