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>
asked Jun 18, 2019 at 11:34

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>
answered Jun 18, 2019 at 11:38

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.