cancel
Showing results for 
Search instead for 
Did you mean: 

Navigation (NEXT/PREV) from Admin Product Edit Page

SOLVED

Navigation (NEXT/PREV) from Admin Product Edit Page

Hello All - I tried to post this earlier but for some reason its not showing up.

 

I want to do the navigation (NEXT/PREV) from the product Edit Page. 

i.e: 

If i click on NEXT button it will take me to the next product.

If i click on PREV button it ill take m to the prev product. 

 

So far, i have found this module online on github as per below and installed this modules successfully. This modules allows the admin to VIEW the product on the Front End from within the product Edit Page. Its a great addition, instead of going to your front end and searching for the product. Saves alot of clicks. Thank you to the author(

for offering it. here is a link to the product:

https://github.com/HexBrain/Magento2ViewProductButton

 

This is what i would like to do now:


public function getButtonData()
{
if(clicked NEXT)
//Save the current settings
//Move to the next product by calling _getNextProduct();
return ['label' => __('NEXT'),'on_click' => $this->_getNextProduct()),'class' => 'view disable','sort_order' => 20];

else if (clicked PREV)
//Save the current settings
//Move to the previous product by calling _getPrevProduct();
return ['label' => __('PREV'),'on_click' => $this->_getPrevProduct()),'class' => 'view disable','sort_order' => 21];

else if (clicked VIEW)
return [
'label' => __('VIEW'),
'on_click' => sprintf("window.open('%s')", $this->_getProductUrl()),
'class' => 'view disable',
'sort_order' => 22];


}

protected function _getNextProduct()
{
///return the next product from DB
}

protected function _getPrevProduct()
{
///return the prev product from DB
}

protected function _getProductUrl()
{
$store = $this->_request->getParam('store');
if (!$store) {
$this->_emulation->startEnvironmentEmulation(null, \Magento\Framework\App\Area::AREA_FRONTEND, true);
$productUrl = $this->_product->loadByAttribute('entity_id', $this->_coreRegistry->registry('product')->getId())->getProductUrl();
$this->_emulation->stopEnvironmentEmulation();

return $productUrl;
} else {
return $this->_product
->loadByAttribute('entity_id', $this->_coreRegistry->registry('product')->getId()
)->setStoreId($store)->getUrlInStore();
}
}

 

thank you for taking your time out to helping me. best!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Navigation (NEXT/PREV) from Admin Product Edit Page

i ended up buying the following module and it does everything that i need. it works with magento2.3.3 even though it shows magento2.1.

https://marketplace.magento.com/wijzijnguru-guru-adminpreviousnext.html

 

View solution in original post

3 REPLIES 3

Re: Navigation (NEXT/PREV) from Admin Product Edit Page

I have made some changes to the code and now i have:

 

public function getButtonDataView()
{
return [
'label' => __('VIEW'),
'on_click' => sprintf("window.open('%s')", $this->_getProductUrl()),
'class' => 'view disable',
'sort_order' => 20
];
}

public function getButtonDataPrev()
{
return [
'label' => __('PREVIOUS'),
'on_click' => $this->_getProductPrevious()),
'class' => 'view disable',
'sort_order' => 21
];
}

public function getButtonDataNext()
{


return [
'label' => __('NEXT'),
'on_click' =>  $this->_getProductNext()),
'class' => 'view disable',
'sort_order' => 22
];
}

/**
* Return product frontend url depends on active store
*
* @return string
*/

protected function _getProductPrevious()
{

//return the previous product

///i dont know what i code i need here

 

}

 

protected function _getProductNext()
{

//return the next product

//i dont know what code i need here

}

 


protected function _getProductUrl()
{
$store = $this->_request->getParam('store');
if (!$store) {
$this->_emulation->startEnvironmentEmulation(null, \Magento\Framework\App\Area::AREA_FRONTEND, true);
$productUrl = $this->_product->loadByAttribute('entity_id', $this->_coreRegistry->registry('product')->getId())->getProductUrl();
$this->_emulation->stopEnvironmentEmulation();

return $productUrl;
} else {
return $this->_product
->loadByAttribute('entity_id', $this->_coreRegistry->registry('product')->getId()
)->setStoreId($store)->getUrlInStore();
}
}
}

Re: Navigation (NEXT/PREV) from Admin Product Edit Page

i ended up buying the following module and it does everything that i need. it works with magento2.3.3 even though it shows magento2.1.

https://marketplace.magento.com/wijzijnguru-guru-adminpreviousnext.html

 

Re: Navigation (NEXT/PREV) from Admin Product Edit Page

This extension isn't availible any more. Do you have other solutions to add this function to Magento 2?