matrix component association issue - magento

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.

Related

Using Spring Boot, Thymeleaf and Oracle: How to dynamically populate the submenus in a web site menu defined in a fragment?

I have a web site that consists of approximately 30 html thymeleaf templates. I have a home_navigation.html fragment that gets included in all templates as the header. This header defines a main navigational menu with popup submenus. The popup submenus under one of my main menus needs to be generated from my oracle database table.
Normally when passing data from a database into a Thymeleaf template I would put the code in the controller to call the java DAO and return a list of Link objects and then add that list in the controller to the model using .setAttribute. Then in the Thymeleaf template I would iterate through the "${List}" in a "th:each" outputting the "<a href..." for each Link object in the list. That is all fine and dandy.
I also can pass parameters into the fragment. So that isn't the problem BUT...
Since the main navigational menu is added as a header fragment into the beginning of every template then I would have to go into every defined controller and add code that would pull the list of Links and pass it into the template and then pass the list into the fragment from every page. that would be approximately 30 times!!!
How...using Spring Boot and Thymeleaf, does someone feed data into a fragment to populate a menu dynamically from a database that is then added as a header fragment into every page/template on the site?
Is there a way to create a controller for the fragment and somehow have every page call the controller for the fragment before the fragment contents are put into every page?
Thank you.
There are a number of ways to solve this problem depending on whether your menu can change while the user is logged in. If it can change then you can create a base controller class that has a method annotated with #ModelAttribute. All of your controllers would inherit from this base class. This method would obtain the menu items and add them to the model each time a page is requested. A simplistic example of such a class is:
#Component
public abstract class BaseController {
#Autowired
private AlphabetService alphabetService;
#ModelAttribute(name = "alphabet")
public List<String> getAlphabet() {
return alphabetService.getCharacters();
}
}
Your page would access them as normal
th:each="character : ${alphabet}"
You could also access the service directly in the page by doing something like
th:each="character: ${#alphabetService.getCharacters()}"
If the menu items do not change while the user is logged in then you could add #SessionAttributes("alphabet") at the class level to the above example and the service method would be called only once when the first page is displayed and cached in the session for future access.

How to use two controllers method in one form on laravel?

I have a productsController and it basicly doing CRUD nicely. But there is a issue. My controller methods getting too long. So I decided to seperate ImageController and Image table from products. Because the images need to has on CRUD.
However, the form which is uploading this items is the same with uploading images. So, what is the best practice to make two controller from one form? Also what should be the route look like ?
Note: This is a general question. Also code is too long. That's why I didn't add the code here.
This is a very broad question, but it seems like you need to set up a relationship between Product and Image models (assuming you are using models with the controllers you mentioned in your question), so that a Product hasOne Image. Then when you save a Product, you can call the store Image method on the Image like this:
$product->image->storeImage($img);
Where $img is the image file you are uploading. The relationship would look like this:
Products.php:
public function image()
{
return $this->hasOne('App\Image');
}
Image.php:
public function product()
{
return $this->belongsTo('App\Product');
}
This is not an exhaustive answer, but hopefully gets you started in the correct path. Of course, you will still need to add other code like the custom "store" function on the Image model, and make sure that you have the correct migrations in place (article_id on the Image model, image_id on the Product model), but this would be one way to separate the code and make your controller lighter. Here is a sample of what you would do in the Image.php model to store an image:
class Image extends Model {
public function storeImage($img){
//code goes here to store image
}
}

Presta shop duplicate action in custom module not working

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?

Including Joomla! 3 module in custom position on custom component

I've seen alot of examples of how to include modules on a custom joomla! component using JModuleHelper::getModules, however, when trying to include modules in a custom position, the array come back empty. Here's my code in my component's template:
<?php
jimport('joomla.application.module.helper');
$modules = JModuleHelper::getModules('comwhcustomer');
foreach ($modules as $module){
echo JModuleHelper::renderModule($module);
}
?>
You'll notice the position I'm passing the getModules function is comwhcustomer. This code is returning a blank array. If I pass "footer", I do successfully get the module in the footer position.
I'm using an adapted protostar tempalte and I have added the comwhcustomer position to the xml definition file for the template. I've created the module in module manager and in the position filed, I've selected the "comwhcustomer" position that shows up in the dropdown. On the modules manager page, I see the module listed in the position selected (comwhcustomer). I've confirmed in the database table #__modules that the position is saved correctly.
However, the array is still coming back empty on the getModules call. What am I missing?
Joomla version 3.4.1
Local environment
Windows IIS
PHP 5.4.24
MySQL db
PS - As an alternative, I have sucessfully loaded the module with JModuleHelper::getModule() however, none of the attributes I define in the module manager come over, because they're not supposed to. I'd like to use the method mentioned above so I can control the module behavior from the manager rather than attributes in the code, because this position will be used in multiple views of this component.
This is my first time posting to SO. I do appreciate the support :-)
itoctopus, you were exactly right! The module itself was not assigned to any pages, that's the piece I was not taking into consideration! Thank you so much for your help! I set it to display on all pages and it worked!
Of course, it doesn't show up on all the other pages because they do not contain a position called "comwhcustomer" so it is exactly what I was looking for!

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

Resources