Presta shop duplicate action in custom module not working - model-view-controller

I am working on a presta shop 1.6/30bees module which has a list view in the backend. 'Edit' and 'Delete' actions are set up and work as expected, however when I use addRowAction('duplicate') to add the duplicate action, I do get a link without the right parameters.
The button is rendered, but the link leaves out the item id and the action name. I thought duplicate is a default action that needs little to no work, however I also do find little documentation on that one.
My module currently extends AdminController, but extending ModuleAdminController did not change the outcome either.
public function renderList() {
// add edit function to list item
$this->addRowAction('edit');
// add duplication function to list item
$this->addRowAction('duplicate');
// add delete function to list item
$this->addRowAction('delete');
return parent::renderList();
}
Am I missing a detail on how to get duplicate to work or am I in the wrong and have to add it like a full custom action?

Related

Laravel 5 - getting data to a view

I think this is slightly different to the usual controller passing data to the view. I have a Project which has one DocumentOne. Within my app, the user creates a Project. This then redirects them to the show page for this project.
So with the project created, and the user on the show page for that project, I display the project ID. I then provide a select menu where the user can select a Document to display. So say I am in Project with the ID of 1, I then decide to show DocumentOne for this project. This displays a form with inputs for DocumentOne.
When the user fills in the form and submits, the data is saved to the database. The Project ID is the foreign key for DocumentOne. The following route is set up for DocumentOne
Route::resource('projects.documentOne', 'DocumentOneController');
Now I have data for DocumentOne which is linked to the Project with an ID of 1. However, if I now go back to the projects show page and then select Document One from the dropdown again, all I see is an empty form. This is obviously because the controller for this is
public function show(Project $project)
{
return view('projects.show', compact('project'));
}
So I am never passing it data for DocumentOne because theoretically it is not created when the Project is first shown. What I want to do is when the Document is selected in the Projects show page, is to have the form populated with whatever is in the database for that Document. If nothing is in the database, then the form will be empty. I have a DocumentOne Controller, but I dont know if I can link this to the Projects show page. I was thinking about doing something like this in the DocumentOne controller
public function show(DocumentOne $documentOne)
{
return view('projects.show', compact('documentOne'));
}
But not sure this will work. Hope I have not been too confusing and you understand what I am attempting, hoping someone can offer advice on how best to handle this situation.
Thanks
In my previous project, I also deal with such requirement, I thought so. Here my solution to solve such requirement.
Actual code calling from ajax.
Routes
get('setFlashData',function(Request $request){
$final_response = array();
$data_information = $request->except('_token');
$request->session()->flash('cmg_quick_create_data', $data_information);
if($request->session()->has('cmg_quick_create_data')){
$final_response['result']['success'] = true;
}
return response()->json($final_response);
});
But according to you requirement:
$data_information = $request->except('_token');
$request->session()->flash('cmg_quick_create_data', $data_information);
My basic functionality was, to share form data from Quick Create Section which is pop-up form to Full create form section, and whenever user click to "Go To Full Form" button from pop up, ajax call mentioned function which will set the flash data and than on destination side I only check weather its contain the flash data or not. and deal according to data.
#if (Session::has('cmg_quick_create_data')) {
{!! Form::model(Session::get('cmg_quick_create_data'),["class"=>"form-horizontal","data-parsley-validate"=>"data-parsley-validate",'role'=>'form','files'=>true]) !!}
#else
{!! Form::open(["class"=>"form-horizontal","data-parsley-validate"=>"data-parsley-validate",'role'=>'form','files'=>true]) !!}
#endif
I can understand this solution might be different from you requirement but hope full to figure out your solution. Look forward to hearing from you if still unclear from my side.

How to make a laravel 5 view composer

I'm still learning Laravel and I'm working on a small project to help me understand better. In the project, I am in need of a global array, so that I may display it or its attributes on every view rendered. sort of on a notification bar, so that each page the user visits, he/she can see the number of notifications (which have been fetched in the background and are stored in the array).
I have done some research, and realized that I have to fetch and compile the array in a view composer I think. But everywhere I go, I cant seem to understand how to make a view composer.
I need to fetch the relevant rows from the database table, and make the resulting array available to each view rendered (I'm thinking attaching it somehow to my layouts/default.blade.php file.). Please help, any and all advice is greatly appreciated:)
You can now inject services on your view
More info here: https://laracasts.com/series/whats-new-in-laravel-5-1/episodes/2
You have to use Sub-Views of laravel blade. I guess your functionality is like a sidebar or like a top bar which will be rendered at every page.
//Your Controller pass data
class YOUR_CONTROLLER extends Controller {
public function index()
{
$data = YOUR_DATA;
return view('YOUR_VIEW_FILE', get_defined_vars());
}
}
//In Your View File
#extends('LAYOUTS_FILE')
#section('YOUR_SECTION')
#include('YOUR_SUB_VIEW_FOR_NOTIFICATION')//You need not pass any data passed all data will be available to this sub view.
#endsection
In your sub view
//Do what ever you want looping logic rendering HTML etc.
//In your layout file just yield or render the section that's it
#yield('YOUR_SECTION')
More explanation can be found Including Sub-Views

matrix component association issue

Background:
I have a running magnto application. I have created a new module inside app/code/locale. Inside this folder I have controller called SyncController.
Inside this controller I am calling a method in model Like below;
<?php
class Connect_SyncController extends Mage_Core_Controller_Front_Action {
function IndexAction() {
}
function ProductAction() {
Mage::getModel('connect/product')->sync();
}
}
?>
Product action in model receives a json input and the json input will contain matrix item and matrix component item.
Problem:
So for it was working fine. Whenever I sent matrix item and component items, those all were added and associated properly. Suddenly there is an problem in associating components to its matrix item. Matrix items and components are being saved successfully no issues with that. But, components are not associating to its parent. Even there is no error throwing. Surprise is, once in a while it works.
I referred below suggestion also;
Cannot associate Simple Products in a Configurable
But there is no up gradation or change in configuration exists in recent past.
Can anyone suggest what may be the issue?
Try to increase max_input_time from php.ini. And restart the apache server.

How do I give my controller function its own template?

I've built a widget module that has this basic controller:
class MyModule_OrderForm_HandlersController extends Mage_Core_Controller_Front_Action{
public function handleroneAction(){
// do some stuff
}
}
So this is giving me a page at mydomain.com/orderform/handlers/handlerone which is great, but how do I give that function its own template file.
I've searched Google for hours and not found a straight forward answer, I hope someone here can help me.
Thanks.
If you are looking for how to create a widget i'd check out http://www.magentocommerce.com/knowledge-base/entry/tutorial-creating-a-magento-widget-part-1/.
But for giving your controller action a template I would check out this article from inchoo:
http://inchoo.net/ecommerce/magento/programatically-create-magento-blocks-and-inject-them-into-layout/
As the article says the proper 'magento way' is to create a block file in your module that extends Mage_Core_Block_template and then insert that block with its template file into the page using layout updates.
The method outlined in the inchoo article lets you skip creating a custom block and layout updates and lets you insert your template directly into the content area of that action.
When you call $this->loadLayout() you apply your site's theme to that action. The template you insert would have everything you want to insert into that page's main content area.
The first param is the type of block you're inserting.In this example we are using Mage_Core_Block_Template, the basic block for asigning templates. The second param of the createBlock() function ('my_block_name_here') can be any arbitrary name. The third param is an array of attributes given to the block. In this example the only attribute we're assigning is 'template'. this is how we tell the block which template to use.

AJAX Page Loader navigation bar

My site is:
http://econrespuestas.com.ar
And i'm having trouble with AJAX page loader integration. When you click on a link in "secondary-menu", it adds it the "current-menu-item" class, but it doesn't remove de "current-menu-item" class from the other ones.
I'm trying to do it with this code:
// highlight the current menu item
jQuery('secondary-menu li').each(function() {
jQuery('thiss').removeClass('current-menu-item');
});
jQuery(thiss).parents('li').addClass('current-menu-item');
but it isn't working. There must be something wrong with the removeClass selector. Could you help me?
Firstly, thiss doesn't exist (unless declared somewhere else). It must be this. In addition try something more like...
jQuery('.current-menu-item').removeClass('current-menu-item');
jQuery(this).parents('li').addClass('current-menu-item');
This is saying "Remove the class current-menu-item from any objects with the class current-menu-item, then add the class current-menu-item to the parent li of the clicked item"
In addition, make sure that in your CSS, .current-menu-item{...} appears after any styling for the non-currently selected item.
See Fiddle: http://jsfiddle.net/6hR9K/2/
Also, unless you have a specific conflict with using the $ sign in place of jQuery, I suggest doing exactly that.
$('.current-menu-item').removeClass('current-menu-item');
$(this).parents('li').addClass('current-menu-item');

Resources