Fetch product url from drop down

Open to all! Ask other shopowners for help.
Post Reply
radhavallabh
Senior Contributor
Posts: 466
Joined: Tue Oct 27, 2020 4:09 am
Phoenix Version: 1.1.0.6
Has thanked: 29 times
Been thanked: 3 times

Fetch product url from drop down

Post by radhavallabh »

Hi dear;
I am trying to assign a related product url to each product so-
I am trying to fetch a product url in the a href tag using a drop down in admin-
like below fetches a id
<?= Products::select('products_id', ['id' => 'fProduct'])->require() ?>
Can you pls help me figure out how to fetch the url using this type of select function?

I am trying to fetch a URL using the above in place of ENTRY ANSWER so it will automatically fetch the URL in each language

-

Code: Select all

<div class="form-group row">
    <label for="fProduct" class="col-form-label col-sm-3 text-left text-sm-right"><?= ENTRY_PRODUCT ?></label>
    <div class="col-sm-9"><?= Products::select('products_id', ['id' => 'fProduct'])->require() ?></div>
  </div>

  <div class="form-group row">
    <label class="col-form-label col-sm-3 text-left text-sm-right"><?= ENTRY_QUESTION ?></label>
    <div class="col-sm-9"><?= $question_input_string ?></div>
  </div>

  <div class="form-group row">
    <label class="col-form-label col-sm-3 text-left text-sm-right"><?= ENTRY_ANSWER ?></label>
    <div class="col-sm-9"><?= $answer_input_string ?></div>
  </div>
Please your help will be deeply appreciated;
Thank you in advance;
Very Warm Regds./
radhavallabh
radhavallabh


Join The Code Co-op to get access to your library in the Code Co-op Forum
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Fetch product url from drop down

Post by ecartz »

radhavallabh wrote: Wed Jul 27, 2022 12:40 pm I am trying to fetch a product url in the a href tag using a drop down in admin-
I don't know what this means.

If you just want to associate a product with a different product, just work with the IDs. You can then use the ID to generate a URL:

Code: Select all

$href = $Admin->catalog('product_info.php', ['products_id' => $product->get('associated_product_id')]);
or in catalog

Code: Select all

$href = $Linker->build('product_info.php', ['products_id' => $product->get('associated_product_id')]);
You can set the associated_product_id on the Product object with a hook listener on productCapabilities.

If you want to change the URL in admin based on a select menu, then you'll need Javascript.
radhavallabh
Senior Contributor
Posts: 466
Joined: Tue Oct 27, 2020 4:09 am
Phoenix Version: 1.1.0.6
Has thanked: 29 times
Been thanked: 3 times

Re: Fetch product url from drop down

Post by radhavallabh »

ecartz wrote: Wed Jul 27, 2022 2:24 pm
radhavallabh wrote: Wed Jul 27, 2022 12:40 pm I am trying to fetch a product url in the a href tag using a drop down in admin-
I don't know what this means.
Sorry for not being precise.
I am trying to make a tabbed module in admin on each product where I could select a URL to associate it with the product.
On catalog size it shall appear as a Button link with text I assign in the module.

Will try the method you suggested and report back , Am also trying to replicate Soft redirect into this module so will come back as and when I hit a block :)

Thank you;
Very Warm Regds./
radhavallabh


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply