Zen Cart Logo
Forums / All Other Contributions/Addons / Stock by Attribute v4.0 addon for v1.3.5-1.3.9

Stock by Attribute v4.0 addon for v1.3.5-1.3.9

Views: 658,356

Results 3,001 to 3,020 of 3,609
24 Sep 2018, 09:08
#3001
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Location:
UK
Posts:
1,326
Plugin Contributions:
0

Stock by Attribute v4.0 addon for v1.3.5-1.3.9

Actually, thought it best to confirm, for you and others, that yes your code change does resolve the issue.

24 Sep 2018, 09:32
#3002
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

simon1066:

Actually, thought it best to confirm, for you and others, that yes your code change does resolve the issue.

Thank you for that. Yes, that was a good action. Cool, I'll incorporate it into github as soon as I can.

25 Sep 2018, 03:26
#3003
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

mc12345678:

I would say that you are correct in the section of code. It would seem that the issue is in the else section of that. The reason I state that is because the first part generates a result from the query and as the error message that is generated suggests, the error message should not be generated when a product is tracked by SBA.

So that leaves one to ask, how then is it that this error is being generated? Well, in the else section, a previous sql result is being accessed. More than likely (which I'll take a closer look at), the query was fully iterated before being stored. What that means is that in order to reuse the result, the query needs to be rewound. Because this software is compatible with older ZC versions, there are two ways to do this.

Changing:

} else {
$products_options_names = $this->_isSBA[(int)$products_id]['sql'];
}

> 
> To:
> ```
   } else {
       $products_options_names = $this->_isSBA[(int)$products_id]['sql'];
        if (method_exists($products_options_names, 'rewind')) {
          $products_options_names->Rewind();
        } else {
          $products_options_names->Move(0);
          $products_options_names->MoveNext();
        }
    }

Will likely resolve the issue for ZC 1.5.5 (in the first section) and pre-ZC 1.5.5 (in the else section that has been added).

Thank you though for reporting this, I hadn't come across such an issue after having addressed other strict associated messages. I did review the list of plugins and considering the error and where it has occurred, I don't believe that they contribute to the issue.

mc12345678:

Thank you for that. Yes, that was a good action. Cool, I'll incorporate it into github as soon as I can.

Incorporated plus a few more code changes to address strict error reporting.

25 Sep 2018, 17:56
#3004
cubmanky avatar

cubmanky

Zen Follower

Join Date:
Jan 2014
Posts:
224
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

mc12345678:

Ok. So. First overall issue I see for this method of implementation as it relates to the current options made available is initially populating all of the product with the associated color attribute "quickly". Now, I haven't gone through the export/import feature that potteryhouse had incorporated in a while, but it seemed to be written with single attribute (color) type functionality and likely could help with that aspect.

So, how to address the rest. Once the color is associated with the product and a quantity of at least 1 is applied (assuming that the stock configuration settings are such not to decrease the quantity), then if want to show the out-of-stock option, a sql query would need to be written to set all of the item's attribute to a quantity of 0. If wanted to just not display the color option, then could use the catalog->iption Values manager to delete the color option from all product (problem there is that when it came back in stock it would also need to be added back to all product which can be done in much the same way but then also have to add back to the attribute tracking section).

Now if the product had not yet been generated, there is the ability to copy attributes from an existing product to the new product including those tracked by SBA.

If the sql route were used, a similar sql statement would be used to change the stock quantity to 1 (or whatever number) when the product came back in stock.

It can also be set to not show the out-of-stock attributes.

Now, I did just think/remember something. Not that long ago, I added a feature that would allow designating that an attribute was not tracked by stock (meaning can get indefinitely until it was turned off), which is a lot like you are seeking. Currently it is controlled only by sql statements, but it supports the ability of saying that an option value is in stock for all product (or all product that have a given option name (color)). The display and management of that feature hasn't been developed yet because the full possibilities haven't quite yet been realized. Didn't want to create something that was going to be difficult to expand upon and would prefer the interface to be understandable.

So I caught on somewhat on what you are talking about. I'm building the site now so the products are being created now without attributes. I knew I could make one and copy attributes to others. when it comes to sql i'm lost that last part you were talking about sounds like what i want to do.

25 Sep 2018, 18:14
#3005
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

cubmanky:

So I caught on somewhat on what you are talking about. I'm building the site now so the products are being created now without attributes. I knew I could make one and copy attributes to others. when it comes to sql i'm lost that last part you were talking about sounds like what i want to do.

I thought that option might be more along what you are wanting, just hadn't thought of it being used that way. :) users can be so creative!

Suggest taking a look at/around post 2725. There had been a new feature added and it does require executing some SQL to make it work, but hopefully it isn't too complicated to figure out. Generally speaking you'll need to look at either/both of the options names manager and/or options values manager to identify the value associated with the needed options.

Hmm, that did remind me. I don't think I implemented copying of product specific information when using that feature and copying product and it's attributes. Will start a new issue on that.

03 Oct 2018, 02:17
#3006
cubmanky avatar

cubmanky

Zen Follower

Join Date:
Jan 2014
Posts:
224
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

So I looked at 2725 I see > Originally Posted by Christian_Wagner View Post

Is there a way to have dropdowns on a page have independent quantities that aren't affected by each other? ie. I'm selling a product (dropdown #1) this is kinda the opposite of what I want to do.
So I made two test products. one I assigned all the colors and linked to SBA, for the second one I copied all the attributes to it. I guess it needs to be dumed down a little more for me.

03 Oct 2018, 03:14
#3007
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

cubmanky:

So I looked at 2725 I see this is kinda the opposite of what I want to do.
So I made two test products. one I assigned all the colors and linked to SBA, for the second one I copied all the attributes to it. I guess it needs to be dumed down a little more for me.

The final "result" is still the same thing. You want to have an option that is always available (until you decide to make it not available) no matter what else is going on around it. In your case though, you want an option value to always be available (many option values really), but each one to be "assigned" as necessary... Now, considering that you've said that you don't really track the stock quantity AND when say "blue" is gone, it is to be gone everywhere, I suggest not assigning variants to the SBA tracked product. If you do, then the existence of the stock quantity will make the option available until the stock quantity is set to 0. And if you set the quantity to 0 (with the code as written), then the option will be unavailable even with the appropriate SQL statement. I do have a "comment" in the code that would work in an opposite way to this, but haven't assigned a constant to it yet.

Anyways, for your situation where options_value_id 143 is to be available for all product that have it assigned in the attributes controller and the product is tracked by SBA, then one sql statement (to address a single option value) would be:

INSERT INTO products_with_attributes_stock_attributes_non_stock  (attribute_type, attribute_type_id, attribute_type_source_id) VALUES  ('OV', 143, 0);

Where the option value id for your color is 143. The option value id can be found in the catalog->Option Values Manager section and is the number to the left of the option value's name... Then, when you want the item to be out-of-stock or "non-existent" you would do a SQL statement like this:

DELETE FROM products_with_attributes_stock_attributes_non_stock  WHERE attribute_type = 'OV' AND attribute_type_id = 143 AND attribute_type_source_id = 0;

Hmmm.. Btw, just thinking about this, because I haven't tried it is that you may need to assign at least one variant to a product to be so tracked... Just thinking a little about the overall assignment(s)/operation(s) that basically the SBA code doesn't kick in unless a product is found in the SBA table which is to have a products_id in the list even if there is otherwise useless information.

17 Oct 2018, 04:43
#3008
cubmanky avatar

cubmanky

Zen Follower

Join Date:
Jan 2014
Posts:
224
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

So I ran the following code and replace # for the Option Value Name. I did this for all 59 colors.

INSERT INTO zc_products_with_attributes_stock_attributes_non_stock  (attribute_type, attribute_type_id, attribute_type_source_id) VALUES  ('OV', #, 0);

I made two test products, added all the colors to one and then copied that attribute to the second one.
I ran the full upgrade script along with the Add all Product Attributes
I can see all colors on my two products.
next I ran the following code

DELETE FROM zc_products_with_attributes_stock_attributes_non_stock  WHERE attribute_type = 'OV' AND attribute_type_id = 2 AND attribute_type_source_id = 0;

2 is the id for white. White still showing as a color option. I have both test products linked to SBA

my site is http://www.visionsinvinyldesigns.com/store1/index.php?main_page=index&cPath=1
click on test or test 2 for products

17 Oct 2018, 04:56
#3009
cubmanky avatar

cubmanky

Zen Follower

Join Date:
Jan 2014
Posts:
224
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

I just went in and add qty as 100 for variant of pick color on test2 product

17 Oct 2018, 10:45
#3010
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

cubmanky:

So I ran the following code and replace # for the Option Value Name. I did this for all 59 colors.

INSERT INTO zc_products_with_attributes_stock_attributes_non_stock (attribute_type, attribute_type_id, attribute_type_source_id) VALUES ('OV', #, 0);

> I made two test products, added all the colors to one and then copied that attribute to the second one.  
> I ran the full upgrade script along with the Add all Product Attributes
> I can see all colors on my two products.
> next I ran the following code
> ```
DELETE FROM zc_products_with_attributes_stock_attributes_non_stock  WHERE attribute_type = 'OV' AND attribute_type_id = 2 AND attribute_type_source_id = 0;

2 is the id for white. White still showing as a color option. I have both test products linked to SBA

my site is http://www.visionsinvinyldesigns.com/store1/index.php?main_page=index&cPath=1
click on test or test 2 for products

cubmanky:

I just went in and add qty as 100 for variant of pick color on test2 product
I want to be sure that we are both considering addressing the same aspect of operation. In absence of the latest message where a variant quantity ended up being applied against an attribute selection, SBA basically would have not been a factor in this display. Now that every attribute variant has been provided a quantity of 100 (though it only needed one of them to have a quantity applied) test2 is actually a product tracked by SBA.

So it seems to me that you're trying to validate that the non-stock feature can be used across the product. While that may be the ultimate goal, there are a few things yet to consider.

At last check all attributes of the test2 product had quantity assigned. As a result of that the non-stock field setting presence/absence will not change the existence of the applicable option. Having stock overrides that an attribute is non-stock tracked as far as being displayed or not.

Then there is the issue of whether an attribute is to be displayed or not and whether it is to be identified as out-of-stock. These other settings can affect whether an option is displayed or not. The important part as far as purchasing is whether the associated selection can be added to the cart. Ie. If the store can not be oversold and a selected combination is entered as not existing, then that combination should not be able to be added to the cart.

Again at my last look, I would say that the test of the "white" attribute would require removing the quantity from the white variant (ie. Removing the variant that has that attribute.)

On another note, it seems that the "Please select color..." option is not setup properly to be a display only, default attribute. I could be wrong.

It does seem that the option name type is correctly set and that the dynamic dropdowns options are correctly set to use the SBA simple select (dropdown) options. I say this because the quantity of available product is shown and I don't see any remnants of the Dynamic Dropdown javascript in the source code.

17 Oct 2018, 12:00
#3011
cubmanky avatar

cubmanky

Zen Follower

Join Date:
Jan 2014
Posts:
224
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

SO I went in and stripped the attributes for both test products, rebeuilt the attributes for test only and linked it the SBA. I just picked the select color and mad it qty of 100 only but then all the other options get populated with a qty number

17 Oct 2018, 13:02
#3012
cubmanky avatar

cubmanky

Zen Follower

Join Date:
Jan 2014
Posts:
224
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

Also if I set the pick a color as read only then in SBA I can not select it to add a qty to.

17 Oct 2018, 13:06
#3013
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

cubmanky:

SO I went in and stripped the attributes for both test products, rebeuilt the attributes for test only and linked it the SBA. I just picked the select color and mad it qty of 100 only but then all the other options get populated with a qty number

I have not been able to reproduce a problem where a specific option value was selected and data entered to be populated causing all option values to be populated with that information.

At least that seems to be what was described above as being attempted.

17 Oct 2018, 13:13
#3014
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

cubmanky:

Also if I set the pick a color as read only then in SBA I can not select it to add a qty to.
Read only or display only? (read only is an option name type, display only is a setting in the attributes controller.)

As to not being able to add quantity to a display only attribute, that is by design. The original idea was that if not able to select the option to add it to the cart, then how could it have a quantity? Now with this concept of using the non-stock option, that may need to be revisited in some way.

17 Oct 2018, 13:31
#3015
cubmanky avatar

cubmanky

Zen Follower

Join Date:
Jan 2014
Posts:
224
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

Attachment 18074
this is what showing on my end.

So click on a color, it shows in stock, but when you click to add to cart gives you a out of stock msg. This is for all colors, now if I click on the pick a color it will add it.

17 Oct 2018, 14:28
#3016
cubmanky avatar

cubmanky

Zen Follower

Join Date:
Jan 2014
Posts:
224
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

So if I make a test product, set the attributes and link it to SBA. I go in an set 20 color in stock and all the others as out of stock, I can then copy the attributes from this test product to others and it will keep the stock/ out of stock settings for all.

Also will say I get > Stock By Attribute (SBA) Stock Page Version 1.5.4 at the top of the Products with Attributes stock page, I'm running 1.5.5 and uploaded the files in the 1.5.5 folder

18 Oct 2018, 04:26
#3017
cubmanky avatar

cubmanky

Zen Follower

Join Date:
Jan 2014
Posts:
224
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

Anything on my end to help with figuring what is going on. I can do the copy attributes over but that could be difficult

18 Oct 2018, 05:47
#3018
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

cubmanky:

Anything on my end to help with figuring what is going on. I can do the copy attributes over but that could be difficult
Well, I guess the first thing is to clearly identify what it is that is needing adjustment?

I have found that the nullDataEntry method in the admin class is unnecessarily adding quotes around text that is later self quoted by ZC. This effects multi-attribute product and was modified in my upload of last month.

I also looked back at the query written to use the non-stock feature (at least the one received via email) and saw that an unsupported attribute_type was identified for use.

18 Oct 2018, 18:19
#3019
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

cubmanky:

So I ran the following code and replace # for the Option Value Name. I did this for all 59 colors.

INSERT INTO zc_products_with_attributes_stock_attributes_non_stock (attribute_type, attribute_type_id, attribute_type_source_id) VALUES ('OV', #, 0);

> I made two test products, added all the colors to one and then copied that attribute to the second one.  
> I ran the full upgrade script along with the Add all Product Attributes
> I can see all colors on my two products.
> next I ran the following code
> ```
DELETE FROM zc_products_with_attributes_stock_attributes_non_stock  WHERE attribute_type = 'OV' AND attribute_type_id = 2 AND attribute_type_source_id = 0;

2 is the id for white. White still showing as a color option. I have both test products linked to SBA

my site is http://www.visionsinvinyldesigns.com/store1/index.php?main_page=index&cPath=1
click on test or test 2 for products

My apologies, if anything in the message before the above message, I referenced the wrong attribute_type. Post 2725 clearly identifies the 4 currently recognized (the values are actually constants that you could change if you wanted, though would be just as easy to execute a sql statement against the table to modify the values already entered.)

The values recognized are:
There are four designated "groups" which are considered capable of being non-stock dependent:
All Option ("AO")
All Values ("AV")
Product's Option ("PO")
Product's Value ("PV")

Now that said, yesterday I tried to take advantage of "AO" against a multi-attribute product where variants were assigned in combinations but did not get the result(s) I thought I expected to get.

So for you, you might want to execute:

UPDATE products_with_attributes_stock_attributes_non_stock SET attribute_type = 'AV' WHERE attribute_type = 'OV';

The above sql statement is executable for ZC 1.5.1 and above from within tools->Install SQL Patches in the ZC admin.

18 Oct 2018, 20:12
#3020
cubmanky avatar

cubmanky

Zen Follower

Join Date:
Jan 2014
Posts:
224
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

So I grabbed the files from https://github.com/mc12345678/Stock_By_Attributes_Combined and uploaded them to my site. I ran the above script and looking in > zc_products_with_attributes_stock_attributes_non_stock and the attribute type is set to AV, Still no luck. On test product I have set the qty for each color individual. for test2 product I just made pick a color at 100 units I have in the out of stock that white is out. Still any color i click on will tell me out of stock when i try to click to add it to the cart.